Multi-threading related error when HP physics is used

Geant4 Version: 11.2
Operating System: macOS Sonoma 14.4, M2
Compiler/Version: clang-1500.3.9.4
CMake Version: 3.28.0

I observed the following warning message when I enable HP physics in serial mode:

Exception: [code: system:22] caught: mutex lock failed: Invalid argument
Non-critical error: mutex lock failure in ~G4Cache<P15G4HadFinalState>.
If the RunManagerKernel has been deleted, it failed to delete an allocated resource
and this destructor is being called after the statics were destroyed.
Exception: [code: system:22] caught: mutex lock failed: Invalid argument

I have a very small Geant4 application (80 lines of code) to reproduce this behavior:

# no problem:
$ PHYSLIST=QGSP_BERT G4RUN_MANAGER_TYPE=Serial ./build/mingle run.mac
# has problem:
$ PHYSLIST=QGSP_BERT_HP G4RUN_MANAGER_TYPE=Serial ./build/mingle run.mac

I reported this in another post. The discussion there is helpful but we did not pin down the real source of the error there.

This is possibly related to 2560 – Program crashes halfway when simulating a large number of particles if use any reference physics list involving HP, and some other recently discovered issues in G4Cache, but @civanch and @dkonst can confirm.