TDatabasePDG is not thread safe, while creating multiple thread only instance cause log spam


ROOT Version: 6.26/06
Platform: Fedora 37 Beta
Compiler: g++ (GCC) 12.2.1 20220819 (Red Hat 12.2.1-2)


It seems that TDatabasePDG is somehow not thread-safe (even after calling ROOT::EnableImplicitMT()), concurrent call to methods like TDatabasePDG::Instance()->GetParticle(xxx)->GetName() can cause segmentation violation.

I came up with an workaround to use thread_local TDatabasePDG db{}, to avoid the segv, while it caused a LOT: Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated (as many as nproc).

My question is

  • Is the thread-unsafe TDatabasePDG implementation considered a BUG, that I should open a ticket and wait for a fix?
  • Is there a way to disable the object already instantiated warning?

Thanks for reporting. Indeed, TDatabasePDG is not thread safe. (It’s also possibly using outdated data.)

Please open a bug report; it should be straight forward to fix this. We would certainly appreciate a PR; it will need locking of ReadPDGTable() and BuildPdgMap(), at least. This will get rid of the message "object already instantiated".

As a workaround you should be able to call TDatabasePDG::Instance()->GetParticle(4) once, either before starting threads, or within a lock, before any other access to TDatabasePDG::Instance().

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