Mutexes when running inside Geant4 threads

I am using Root inside a multithreaded Geant4 simulation, and I obtain a strange crash when the dictionary of one of my custom classes is loaded. The dictionary is loaded by two threads concurrently, and using gdb I came to the conclusion that the write lock:


at line 2925 of TClass.cxx is not respected. I can make the two threads step over it at the same time using the debugger, while I’d expect that the second one should be blocked until the first one releases the lock.

Supposing I’m right, I need help to understand why this happens. It came into my mind that thread-safety in Root might require to be explicitly enabled at runtime (so that the lock mechanisms actually work) or that for using Root in a multithreaded environment it could be necessary to enable some flags at compile time. About the second point, here are the threading-related lines in the cmake output of my build:

-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Compiler Flags: -g  -std=c++14 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread
-- Native target architecture is X86
-- Threads disabled.
-- Doxygen disabled.
-- Go bindings disabled.
-- LLVM host triple: x86_64-unknown-linux-gnu
-- LLVM default target triple: x86_64-unknown-linux-gnu
-- Building with -fPIC
-- Constructing LLVMBuild project information
-- Linker detection: GNU ld
-- SysLibs: rt;dl;tinfo;-lpthread;/usr/lib/
-- Targeting X86
-- Enabled support for:  asimage builtin_afterimage builtin_clang builtin_davix builtin_gl2ps builtin_llvm builtin_vdt clad dataframe davix exceptions fftw3 fitsio http mathmore mlp minuit2 opengl pgsql roofit runtime_cxxmodules shared sqlite ssl tmva tmva-pymva spectrum vdt x11 xml

Actually, the -- Threads disabled. line looks suspect, but I really don’t know how to interpret it.
Thanks for any help you might provide.

Please read tips for efficient and successful posting and posting code

_ROOT Version: 6.20.00
_Platform: Archlinux
_Compiler: GCC 10.2.0

The ROOT code is thread safe if and only if you execute (directly or indirectly):


without this call the ROOT locks (R__WRITE_LOCKGUARD(ROOT::gCoreMutex);) are (intentionally) inactive.

-- Threads disabled.

This indicates that LLVM is not build with its own thread support (that would be redundant with the one ROOT uses).

Thanks, that’s exactly the information I was looking for. Evidently I did not searched enough in the documentation, sorry for that.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.