ReinitializeGemotry will cause SensitiveDetector crash

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

Geant4 Version: 11.10
Operating System: Windows
Compiler/Version: VC 2019
CMake Version: 3.16

I am new to the forum. I tried to add one line code G4RunManager::GetRunManager()->ReinitializeGeometry(); in the B2a example like the following

void DetectorConstruction::SetTargetMaterial(G4String materialName)




I understand that it is not necessarily to reinitialize geometry when I changed the material of the target. But just for illustration purpose, I chose this example and put this line in this function.

After that I built and ran the B2a program in the Qt interface. In the command line I typed the following command

/B2/det/setTargetMaterial G4_Pb
/run/beamOn 1

Then I got the exception error

-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : GeomMgt0003
issued by : G4GeometryManager::SetMaximumExtent()
Extent can be set only BEFORE creating any geometry object!
*** Fatal Exception *** core dump ***
**** Track information is not available at this moment
**** Step information is not available at this moment

-------- EEEE -------- G4Exception-END --------- EEEE ------

I thought that something might be wrong in the function G4VPhysicalVolume* DetectorConstruction::DefineVolumes(). So, I commented out the line
as follows.
G4VPhysicalVolume* DetectorConstruction::DefineVolumes()



// G4GeometryManager::GetInstance()->SetWorldMaximumExtent(worldLength);



I rebuilt and rerun the code and typed the same command in the command window

/B2/det/setTargetMaterial G4_Pb
/run/beamOn 1

then I got the exception

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : DET1010
issued by : G4SDStructure::AddNewDetector()
TrackerChamberSD had already been stored in /. Object pointer is overwritten.
It’s users’ responsibility to delete the old sensitive detector object.
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

I think this problem might be caused by the reinitialization of the geometry and the sensitive detector. I googled the problem. But it seems that I did not get any answer about the exception. Can anyone give me some idea on this problem? Thanks.