I'm using Geant4 10.04 patch01, but I think the code base hasn't changed on this topic. When you invoke `G4PhysicsTable::insertAt()` it won't check the table size, so it sometimes tries to insert on empty vectors, and it will crash. For example, the following code will crash at `physics_table_->insertAt(4, v);`. ```cpp auto physics_table_ = new G4PhysicsTable(10); // specify the table size as 10 in its constructor, but it does only reserve() rather than resize() auto v = new G4PhysicsOrderedFreeVector(); physics_table_->insertAt(4, v); delete physics_table_; delete v; ``` As a comparison, the following code works. ```cpp auto physics_table_ = new G4PhysicsTable(); // not specify the table size physics_table_->resize(10); // make sure the table size is 10 auto v = new G4PhysicsOrderedFreeVector(); physics_table_->insertAt(4, v); delete physics_table_; delete v; ```
Michael Kelsey gave me a comment on this. https://geant4-forum.web.cern.ch/t/how-can-i-use-g4physicstable-insertat/635/2
Thank you for reporting this. The further communication on the related Forum topic https://geant4-forum.web.cern.ch/t/how-can-i-use-g4physicstable-insertat/635 showed the protection in insertAt() against idx > entries() is required. This fix will be included in the next patch release.