You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the logic to save the TGeoManager into the root file is the following:
////////// Writing the geometry in TGeoManager format to the ROOT file
////////// Need to fork and do it in child process, to prevent occasional seg.fault
pid_t pid;
pid = fork();
if (pid < 0) {
perror("fork error:");
exit(1);
}
// child process
if (pid == 0) {
// writing the geometry object
freopen("/dev/null", "w", stdout);
freopen("/dev/null", "w", stderr);
REST_Display_CompatibilityMode = true;
// We wait the father process ends properly
sleep(5);
// Then we just add the geometry
auto file = new TFile(filename, "update");
TGeoManager* geoManager = gdml->CreateGeoManager();
file->cd();
geoManager->SetName("Geometry");
geoManager->Write();
file->Close();
exit(0);
}
// father process
else {
int stat_val = 0;
pid_t child_pid;
printf("Writing geometry ... \n");
}
I find this overly complex for what it is trying to achieve, I think we should simplify it.
In principle something similar to the following code could be used:
TGeoManager* geoManager = gdml->CreateGeoManager();
if (geoManager) {
geoManager->Write("Geometry");
delete geoManager;
} else {
cout << "Error: could not create geometry" << endl;
}
However if this change is implemented, ocassional segfaults will appear, as the description on the current implementation describes.
I think we should fix the underlying issue which is likely on the core repository.
Perhaps @nkx111 which I think authored the original implementation can describe how it works, and why a fork is necessary.
@juanangp or @jgalan perhaps you also have some insights on this.
The text was updated successfully, but these errors were encountered:
Can you try to remove delete geoManager; it might happen that you erase the pointer while it is still trying to write it, also memory management of root is not clear to me.
Can you try to remove delete geoManager; it might happen that you erase the pointer while it is still trying to write it, also memory management of root is not clear to me.
Perhaps @nkx111 which I think authored the original implementation can describe how it works, and why a fork is necessary.
To some unknown reason the final step saving geometry to root file will crash occasionally. It happens randomly with about 3% probablity. So I added this fork step, to protect the main process, and make the pipeline always green.
Currently the logic to save the
TGeoManager
into the root file is the following:I find this overly complex for what it is trying to achieve, I think we should simplify it.
In principle something similar to the following code could be used:
However if this change is implemented, ocassional segfaults will appear, as the description on the current implementation describes.
I think we should fix the underlying issue which is likely on the core repository.
Perhaps @nkx111 which I think authored the original implementation can describe how it works, and why a fork is necessary.
@juanangp or @jgalan perhaps you also have some insights on this.
The text was updated successfully, but these errors were encountered: