diff --git a/External/CheckerGccPlugins/THREAD_CHECKS b/External/CheckerGccPlugins/THREAD_CHECKS index fc6e379b66bcf98b7670aff0918dea3c29b56d81..da921ab4cfb9d64a4865e898b9f3499b21210537 100644 --- a/External/CheckerGccPlugins/THREAD_CHECKS +++ b/External/CheckerGccPlugins/THREAD_CHECKS @@ -128,6 +128,7 @@ void f1() Passing a std::atomic value of a fundamental type is considered ok. +Passing mutexes also considered ok. Can suppress by: - Declaring value as thread_local. diff --git a/External/CheckerGccPlugins/share/thread3_test.ref b/External/CheckerGccPlugins/share/thread3_test.ref index ddb3db839bcbae52382f0fdb7cb5bcca57ee4c7d..afdceed20df38f4271469bc8f732faf0a3068b0a 100644 --- a/External/CheckerGccPlugins/share/thread3_test.ref +++ b/External/CheckerGccPlugins/share/thread3_test.ref @@ -1,38 +1,38 @@ -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx: In function 'void f1()': -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx:27:15: warning: Static expression 'y1' passed to pointer or reference function argument of 'foo1' within function 'void f1()'; may not be thread-safe. +/home/sss/atlas/rootaccess/../test/thread3_test.cxx: In function 'void f1()': +/home/sss/atlas/rootaccess/../test/thread3_test.cxx:30:7: warning: Static expression 'y1' passed to pointer or reference function argument of 'foo1' within function 'void f1()'; may not be thread-safe. foo1(3, &y1); - ^ -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx:15:12: note: Declared here: + ~~~~^~~~~~~~ +/home/sss/atlas/rootaccess/../test/thread3_test.cxx:18:12: note: Declared here: static int y1; ^~ -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx:27:15: note: See <https://twiki.cern.ch/twiki/bin/view/AtlasComputing/CheckerGccPlugins#thread_plugin>. +/home/sss/atlas/rootaccess/../test/thread3_test.cxx:30:7: note: See <https://twiki.cern.ch/twiki/bin/view/AtlasComputing/CheckerGccPlugins#thread_plugin>. foo1(3, &y1); - ^ -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx:28:14: warning: Static expression 'y1' passed to pointer or reference function argument of 'foo2' within function 'void f1()'; may not be thread-safe. + ~~~~^~~~~~~~ +/home/sss/atlas/rootaccess/../test/thread3_test.cxx:31:7: warning: Static expression 'y1' passed to pointer or reference function argument of 'foo2' within function 'void f1()'; may not be thread-safe. foo2(3, y1); - ^ -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx:15:12: note: Declared here: + ~~~~^~~~~~~ +/home/sss/atlas/rootaccess/../test/thread3_test.cxx:18:12: note: Declared here: static int y1; ^~ -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx:28:14: note: See <https://twiki.cern.ch/twiki/bin/view/AtlasComputing/CheckerGccPlugins#thread_plugin>. +/home/sss/atlas/rootaccess/../test/thread3_test.cxx:31:7: note: See <https://twiki.cern.ch/twiki/bin/view/AtlasComputing/CheckerGccPlugins#thread_plugin>. foo2(3, y1); - ^ -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx:29:15: warning: Static expression 'y1' passed to pointer or reference function argument of 'foo3' within function 'void f1()'; may not be thread-safe. + ~~~~^~~~~~~ +/home/sss/atlas/rootaccess/../test/thread3_test.cxx:32:7: warning: Static expression 'y1' passed to pointer or reference function argument of 'foo3' within function 'void f1()'; may not be thread-safe. foo3(3, &y1); - ^ -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx:15:12: note: Declared here: + ~~~~^~~~~~~~ +/home/sss/atlas/rootaccess/../test/thread3_test.cxx:18:12: note: Declared here: static int y1; ^~ -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx:29:15: note: See <https://twiki.cern.ch/twiki/bin/view/AtlasComputing/CheckerGccPlugins#thread_plugin>. +/home/sss/atlas/rootaccess/../test/thread3_test.cxx:32:7: note: See <https://twiki.cern.ch/twiki/bin/view/AtlasComputing/CheckerGccPlugins#thread_plugin>. foo3(3, &y1); - ^ -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx: In function 'void f2()': -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx:48:11: warning: Static expression 'c1' passed to pointer or reference function argument of 'C::foo' within function 'void f2()'; may not be thread-safe. + ~~~~^~~~~~~~ +/home/sss/atlas/rootaccess/../test/thread3_test.cxx: In function 'void f2()': +/home/sss/atlas/rootaccess/../test/thread3_test.cxx:51:9: warning: Static expression 'c1' passed to pointer or reference function argument of 'C::foo' within function 'void f2()'; may not be thread-safe. c1.foo(); - ^ -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx:43:10: note: Declared here: + ~~~~~~^~ +/home/sss/atlas/rootaccess/../test/thread3_test.cxx:46:10: note: Declared here: static C c1; ^~ -/afs/cern.ch/user/s/ssnyder/atlas-work3/External/CheckerGccPlugins/test/thread3_test.cxx:48:11: note: See <https://twiki.cern.ch/twiki/bin/view/AtlasComputing/CheckerGccPlugins#thread_plugin>. +/home/sss/atlas/rootaccess/../test/thread3_test.cxx:51:9: note: See <https://twiki.cern.ch/twiki/bin/view/AtlasComputing/CheckerGccPlugins#thread_plugin>. c1.foo(); - ^ + ~~~~~~^~ diff --git a/External/CheckerGccPlugins/src/thread_plugin.cxx b/External/CheckerGccPlugins/src/thread_plugin.cxx index 9e27834919d320b10b2834acf286e28c4ed821a4..0c904c844cffb3d03d0cffced8d9c0e7b7a4bdd6 100644 --- a/External/CheckerGccPlugins/src/thread_plugin.cxx +++ b/External/CheckerGccPlugins/src/thread_plugin.cxx @@ -379,6 +379,7 @@ bool is_mutex (tree type) TFF_SCOPE + TFF_CHASE_TYPEDEF); if (strcmp (name, "std::mutex") == 0) return true; + if (strcmp (name, "std::shared_timed_mutex") == 0) return true; if (strcmp (name, "std::recursive_mutex") == 0) return true; if (strcmp (name, "TVirtualMutex") == 0) return true; return false; @@ -1088,6 +1089,9 @@ void check_pass_static_by_call (Attributes_t attribs, if (fndecl && is_atomic (arg_test) && is_atomic (DECL_CONTEXT (fndecl))) return; + // Ok if it's a mutex. + if (is_mutex (arg_test)) return; + // FNDECL could be null in the case of a call through a function pointer. // Try to print a nice error in that case. tree fnerr = fndecl; diff --git a/External/CheckerGccPlugins/test/thread3_test.cxx b/External/CheckerGccPlugins/test/thread3_test.cxx index 514b21d86f3350d8bfd0ce50fc00c04529b4dca2..17b942ce16bb6f62693789826279c7e62feaf871 100644 --- a/External/CheckerGccPlugins/test/thread3_test.cxx +++ b/External/CheckerGccPlugins/test/thread3_test.cxx @@ -9,6 +9,9 @@ template <class T> struct atomic { atomic& operator++ (); T val() const; }; + +class mutex {}; +class shared_timed_mutex {}; } @@ -77,3 +80,11 @@ void f6() { foo4 (foo5); } + + +std::shared_timed_mutex m; +void f7 (std::shared_timed_mutex&); +void f8() +{ + f7(m); +}