Patch Detail
Show a patch.
GET /api/patches/18390/?format=api
{ "id": 18390, "url": "https://patchwork.libcamera.org/api/patches/18390/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18390/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20230313204134.2769860-1-nicolas@ndufresne.ca>", "date": "2023-03-13T20:41:35", "name": "[libcamera-devel,RFC] libcamera: base: Make the registration of log categories atomic", "commit_ref": "2ccca099d3cbdfa32f0a8bfd2168873b7b803159", "pull_url": null, "state": "accepted", "archived": false, "hash": "7c70dd9fc17abfa3fd1be71faf45bf40664388de", "submitter": { "id": 30, "url": "https://patchwork.libcamera.org/api/people/30/?format=api", "name": "Nicolas Dufresne", "email": "nicolas@ndufresne.ca" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18390/mbox/", "series": [ { "id": 3804, "url": "https://patchwork.libcamera.org/api/series/3804/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3804", "date": "2023-03-13T20:41:35", "name": "[libcamera-devel,RFC] libcamera: base: Make the registration of log categories atomic", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3804/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18390/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18390/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0066ABD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Mar 2023 20:44:48 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4A423626D9;\n\tMon, 13 Mar 2023 21:44:48 +0100 (CET)", "from madras.collabora.co.uk (madras.collabora.co.uk\n\t[IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 235AC62674\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Mar 2023 21:44:46 +0100 (CET)", "from nicolas-tpx395.lan (192-222-136-102.qc.cable.ebox.net\n\t[192.222.136.102])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (4096 bits)\n\tserver-digest SHA256)\n\t(No client certificate requested) (Authenticated sender: nicolas)\n\tby madras.collabora.co.uk (Postfix) with ESMTPSA id 7A02E6603082;\n\tMon, 13 Mar 2023 20:44:45 +0000 (GMT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1678740288;\n\tbh=SuBAYov8WSgivIUm8GhL31Nd0UNTaweAN+fdeAW7/9s=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=mNLYwrCnwZgXN21Fvh1vDenIMzCRDXjJjtu+K7hVPryur17d+ic+uHZpPizQxo1e6\n\tX/fKBPALRqWpqfbqjskUUvMgxXx+PD9z+0O1aZTKNo3LCS1FooTdNkT8NYxtye+qfn\n\tyv2JBc3jAI4pVfgRGKM2bkjInyPLnIE4GWW1y4A+Fnv4XddQl7SAdRzZLh22lqrayZ\n\t9lUG7Wp7+RoOYveDTxguCGpi88Hvg9qbpKIc0jfiGJ/7y9QID2DdavlCn5JvPf3MQn\n\tmnfsF6ksckkdOZTrSJyW9cFlA8HOsdXpRgAeyTb33oCdqoP/1vkpH1cgl0vEQu20zf\n\toWpCXd1lfGgMQ==", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 13 Mar 2023 16:41:35 -0400", "Message-Id": "<20230313204134.2769860-1-nicolas@ndufresne.ca>", "X-Mailer": "git-send-email 2.39.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC PATCH] libcamera: base: Make the\n\tregistration of log categories atomic", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "From": "Nicolas Dufresne via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Nicolas Dufresne <nicolas@ndufresne.ca>", "Cc": "Nicolas Dufresne <nicolas.dufresne@collabora.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n\nLogger:::create() is not currently thread safe and causes crashes\nnoticeable on RaspberryPi 4. This adds a mutex around the creation\nof categories.\n\nSigned-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n---\n\n src/libcamera/base/log.cpp | 3 +++\n 1 file changed, 3 insertions(+)\n\nThis is a quick fix. The crash I'm getting is very frequent, the backtrace\nis the following. Pretty much 50% of the time on Raspberry Pi using:\n\n gst-launch-1.0 libcamerasrc ! queue ! xvimagesink\n\nThread 6 \"gst-launch-1.0\" received signal SIGSEGV, Segmentation fault.\n[Switching to Thread 0x7ff48cc180 (LWP 88100)]\n0x0000007ff5f48a40 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(char const*) const () from /lib/aarch64-linux-gnu/libstdc++.so.6\n(gdb) bt\n#0 0x0000007ff5f48a40 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(char const*) const () at /lib/aarch64-linux-gnu/libstdc++.so.6\n#1 0x0000007ff664efe0 in std::operator==<char, std::char_traits<char>, std::allocator<char> >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*)\n (__lhs=<error reading variable: Cannot access memory at address 0x705f317073696b7a>, __rhs=0x7ff61c4a28 \"Event\") at /usr/include/c++/10/bits/basic_string.h:6187\n#2 0x0000007ff61b48d4 in operator()<libcamera::LogCategory*>(libcamera::LogCategory*) const (__closure=0x7ff48cb008, c=0x705f317073696b72) at ../src/libcamera/base/log.cpp:748\n#3 0x0000007ff61b4910 in __gnu_cxx::__ops::_Iter_pred<libcamera::Logger::findCategory(char const*) const::<lambda(auto:2)> >::operator()<__gnu_cxx::__normal_iterator<libcamera::LogCategory* const*, std::vector<libcamera::LogCategory*> > >(__gnu_cxx::__normal_iterator<libcamera::LogCategory* const*, std::vector<libcamera::LogCategory*, std::allocator<libcamera::LogCategory*> > >)\n (this=0x7ff48cb008, __it=0x705f317073696b72) at /usr/include/c++/10/bits/predefined_ops.h:316\n#4 0x0000007ff61b487c in std::__find_if<__gnu_cxx::__normal_iterator<libcamera::LogCategory* const*, std::vector<libcamera::LogCategory*> >, __gnu_cxx::__ops::_Iter_pred<libcamera::Logger::findCategory(char const*) const::<lambda(auto:2)> > >(__gnu_cxx::__normal_iterator<libcamera::LogCategory* const*, std::vector<libcamera::LogCategory*, std::allocator<libcamera::LogCategory*> > >, __gnu_cxx::__normal_iterator<libcamera::LogCategory* const*, std::vector<libcamera::LogCategory*, std::allocator<libcamera::LogCategory*> > >, __gnu_cxx::__ops::_Iter_pred<libcamera::Logger::findCategory(char const*) const::<lambda(auto:2)> >, std::random_access_iterator_tag) (__first=0x705f317073696b72, __last=0x303100736d617261, __pred=...) at /usr/include/c++/10/bits/stl_algobase.h:1959\n#5 0x0000007ff61b46b4 in std::__find_if<__gnu_cxx::__normal_iterator<libcamera::LogCategory* const*, std::vector<libcamera::LogCategory*> >, __gnu_cxx::__ops::_Iter_pred<libcamera::Logger::findCategory(char const*) const::<lambda(auto:2)> > >(__gnu_cxx::__normal_iterator<libcamera::LogCategory* const*, std::vector<libcamera::LogCategory*, std::allocator<libcamera::LogCategory*> > >, __gnu_cxx::__normal_iterator<libcamera::LogCategory* const*, std::vector<libcamera::LogCategory*, std::allocator<libcamera::LogCategory*> > >, __gnu_cxx::__ops::_Iter_pred<libcamera::Logger::findCategory(char const*) const::<lambda(auto:2)> >)\n (__first=0x555582c130, __last=0x303100736d617261, __pred=...) at /usr/include/c++/10/bits/stl_algobase.h:1974\n#6 0x0000007ff61b4648 in std::find_if<__gnu_cxx::__normal_iterator<libcamera::LogCategory* const*, std::vector<libcamera::LogCategory*> >, libcamera::Logger::findCategory(char const*) const::<lambda(auto:2)> >(__gnu_cxx::__normal_iterator<libcamera::LogCategory* const*, std::vector<libcamera::LogCategory*, std::allocator<libcamera::LogCategory*> > >, __gnu_cxx::__normal_iterator<libcamera::LogCategory* const*, std::vector<libcamera::LogCategory*, std::allocator<libcamera::LogCategory*> > >, struct {...}) (__first=0x555582c130, __last=0x303100736d617261, __pred=...) at /usr/include/c++/10/bits/stl_algo.h:3929\n#7 0x0000007ff61b3f60 in libcamera::Logger::findCategory(char const*) const (this=0x7ff61ec968 <libcamera::Logger::instance()::instance>, name=0x7ff61c4a28 \"Event\") at ../src/libcamera/base/log.cpp:748\n#8 0x0000007ff61b3fc4 in libcamera::LogCategory::create(char const*) (name=0x7ff61c4a28 \"Event\") at ../src/libcamera/base/log.cpp:791\n#9 0x0000007ff61a9ffc in libcamera::logCategoryEvent() () at ../src/libcamera/base/event_dispatcher.cpp:17\n#10 0x0000007ff61aac5c in libcamera::EventDispatcherPoll::poll(std::vector<pollfd, std::allocator<pollfd> >*) (this=0x7fe8006f90, pollfds=0x7ff48cb3e8) at ../src/libcamera/base/event_dispatcher_poll.cpp:216\n#11 0x0000007ff61aa8fc in libcamera::EventDispatcherPoll::processEvents() (this=0x7fe8006f90) at ../src/libcamera/base/event_dispatcher_poll.cpp:160\n#12 0x0000007ff61be0bc in libcamera::Thread::exec() (this=0x55555d0380) at ../src/libcamera/base/thread.cpp:341\n#13 0x0000007ff6643e88 in libcamera::CameraManager::Private::run() (this=0x55555d0370) at ../src/libcamera/camera_manager.cpp:122\n#14 0x0000007ff61be038 in libcamera::Thread::startThread() (this=0x55555d0380) at ../src/libcamera/base/thread.cpp:319\n#15 0x0000007ff61c2070 in std::__invoke_impl<void, void (libcamera::Thread::*)(), libcamera::Thread*>(std::__invoke_memfun_deref, void (libcamera::Thread::*&&)(), libcamera::Thread*&&)\n (__f=@0x5555852ef0: (void (libcamera::Thread::*)(class libcamera::Thread * const)) 0x7ff61bdf38 <libcamera::Thread::startThread()>, __t=@0x5555852ee8: 0x55555d0380) at /usr/include/c++/10/bits/invoke.h:73\n#16 0x0000007ff61c1f88 in std::__invoke<void (libcamera::Thread::*)(), libcamera::Thread*>(void (libcamera::Thread::*&&)(), libcamera::Thread*&&)\n (__fn=@0x5555852ef0: (void (libcamera::Thread::*)(class libcamera::Thread * const)) 0x7ff61bdf38 <libcamera::Thread::startThread()>) at /usr/include/c++/10/bits/invoke.h:95\n#17 0x0000007ff61c1eec in std::thread::_Invoker<std::tuple<void (libcamera::Thread::*)(), libcamera::Thread*> >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) (this=0x5555852ee8)\n at /usr/include/c++/10/thread:264\n#18 0x0000007ff61c1ea4 in std::thread::_Invoker<std::tuple<void (libcamera::Thread::*)(), libcamera::Thread*> >::operator()() (this=0x5555852ee8) at /usr/include/c++/10/thread:271\n#19 0x0000007ff61c1e84 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (libcamera::Thread::*)(), libcamera::Thread*> > >::_M_run() (this=0x5555852ee0) at /usr/include/c++/10/thread:215\n#20 0x0000007ff5ee1cac in () at /lib/aarch64-linux-gnu/libstdc++.so.6\n#21 0x0000007ff7c78648 in start_thread (arg=0x7ff48cba80) at pthread_create.c:477\n#22 0x0000007ff7bcec1c in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78", "diff": "diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\nindex 55fbd7b0..c8045ef7 100644\n--- a/src/libcamera/base/log.cpp\n+++ b/src/libcamera/base/log.cpp\n@@ -21,6 +21,7 @@\n #include <libcamera/logging.h>\n \n #include <libcamera/base/backtrace.h>\n+#include <libcamera/base/mutex.h>\n #include <libcamera/base/thread.h>\n #include <libcamera/base/utils.h>\n \n@@ -788,6 +789,8 @@ LogCategory *Logger::findCategory(const char *name) const\n */\n LogCategory *LogCategory::create(const char *name)\n {\n+\tstatic Mutex mutex_;\n+\tMutexLocker locker(mutex_);\n \tLogCategory *category = Logger::instance()->findCategory(name);\n \n \tif (!category) {\n", "prefixes": [ "libcamera-devel", "RFC" ] }