Skip to content
Snippets Groups Projects
Commit dd40bf35 authored by Benjamin Morgan's avatar Benjamin Morgan
Browse files

Address problem reported in ATLAS-7273

Triaged to likely static deletion order in G4ios, where use of std::cout
may result in accessing a no-longer present resource. Addressed upstream
in Geant4 in SIM-879.

Backport patch from SIM-879 from Geant4 to ATLAS' 10.6.3 version.
parent 80b5a73d
No related branches found
No related tags found
No related merge requests found
...@@ -44,10 +44,6 @@ inline G4strstreambuf::G4strstreambuf() ...@@ -44,10 +44,6 @@ inline G4strstreambuf::G4strstreambuf()
inline G4strstreambuf::~G4strstreambuf() inline G4strstreambuf::~G4strstreambuf()
//////////////////////////////////////// ////////////////////////////////////////
{ {
// flushing buffer...
// std::cout is used because destination object may not be alive.
if(count !=0) std::cout << buffer;
delete [] buffer; delete [] buffer;
} }
......
...@@ -78,6 +78,8 @@ void G4iosInitialization() ...@@ -78,6 +78,8 @@ void G4iosInitialization()
void G4iosFinalization() void G4iosFinalization()
{ {
_G4cout_p()->flush();
_G4cerr_p()->flush();
delete _G4cout_p(); _G4cout_p() = &std::cout; delete _G4cout_p(); _G4cout_p() = &std::cout;
delete _G4cerr_p(); _G4cerr_p() = &std::cerr; delete _G4cerr_p(); _G4cerr_p() = &std::cerr;
delete _G4coutbuf_p(); _G4coutbuf_p() = nullptr; delete _G4coutbuf_p(); _G4coutbuf_p() = nullptr;
...@@ -104,6 +106,9 @@ std::ostream G4cout(&G4coutbuf); ...@@ -104,6 +106,9 @@ std::ostream G4cout(&G4coutbuf);
std::ostream G4cerr(&G4cerrbuf); std::ostream G4cerr(&G4cerrbuf);
void G4iosInitialization() {} void G4iosInitialization() {}
void G4iosFinalization() {} void G4iosFinalization() {
G4cout.flush();
G4cerr.flush();
}
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment