*** Break *** segmentation violation while running macro

Hi,

I am trying to run a macro test.C at first it compiled and run without any issues. When I add some piece of code from lines 616-750 and lines 798-809, it crashes with segmentation violation. I commented the lines above so returning back to original well-running code, but I get the same error don’t know why?
I uploaded the macro test.C, the header test.h and log file with error message.

I run macro as:

gSystem->Load("libDelphes");
.L test.C
test m;
m.Loop();

More info:
macro is created using MakeClass. It run over Drell-Yan sample generated locally by Madgraph5 and simulated with Delphes.


ROOT Version: root-6.18.04
Platform: Ubuntu18.04
Delphes version: Delphes-3.4.2
Madgraph version: MG5_aMC_2.7.3


Thanks for help in advance,
Aya

test.C (26.9 KB)
test.h (69.8 KB)
log.txt (43.8 KB)

Hi @Aya_Beshr ,
I can’t tell what the cause of the crash is by reading the code (it has to do with creation of TFiles and/or writing objects to those TFiles).

Can you reduce the amount of code in the reproducer and/or make it so we can run it ourselves, so we can debug it (e.g. by providing mock input files)?

Cheers,
Enrico

Hi @eguiraud

I have reduced the code and also produced a very small DrellYan sample with only 10 events (for usage as input for testing). I have uploaded both.

DemoAnalyzer.C (5.2 KB)
DrellYan.root (705.3 KB)

Thanks,
Aya

Thanks @Aya_Beshr ,
can you please upload DemoAnalyzer.h too?

Yah sure!
DemoAnalyzer.h (69.9 KB)

Ah I also need Delphes to run this…uhm it will take a while :sweat_smile:

Sorry for that, you might not need to.

Actually, I have just run the original code on 10 events only. I found that there is a warning giving at the beginning:

Warning in <TFile::Init>: file /home/aya/Desktop/Pheno_Work/analysis/Results/output_demo.root probably not closed, cannot read free segments
Warning in <TFile::Init>: file /home/aya/Desktop/Pheno_Work/analysis/Results/output_demo.root has no keys

There is problem with closing the file, it may be the cause for segmentation breaking.

I defined it as:

TFile *op_file = new TFile("/home/aya/Desktop/Pheno_Work/analysis/Results/output_demo.root", "UPDATE");
op_file->Write();
op_file->Close();

Could you kindly clarify what is the key for a file? coz the problem is solved and code ran without issues when I replace "UPDATE" with "RECREATE"

Thanks,
Aya

A key in a TFile is simply the “name of something in the file”.
Most likely the error message means that you are re-opening a file without having closed it first.

I compiled delphes but still can’t run the code because of:

      TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("/media/aya/LinuxSpace/MyWork_Final_Samples/DY_BG_14TeV_SMfull_GEN/DY_BG_14TeV_SMfull_pythia8_CMSPhaseII-0PU_GEN-SIM.root");
      if (!f || !f->IsOpen()) {
         f = new TFile("/media/aya/LinuxSpace/MyWork_Final_Samples/DY_BG_14TeV_SMfull_GEN/DY_BG_14TeV_SMfull_pythia8_CMSPhaseII-0PU_GEN-SIM.root");

(I don’t have access to that file)

This file is on my local laptop, so you can kindly download the root file I just uploaded instead and define a path for it something like,

TFile *input_file = new TFile("/path/to/DrellYan.root", "READ");

or with any other way that you kindly prefer.

Sorry, I have changed the permission access for files, here it is
DrellYan.root (705.3 KB)

Hi,
after changing those filenames in DemoAnalyzer.h and DemoAnalyzer.C to opening the file DrellYan.root that you shared, things look fine on my side (i.e. I can’t reproduce the crash). This is what I run:

gSystem->Load("libDelphes")
.L DemoAnalyzer.C
DemoAnalyzer m
m.Loop()

and this is what I get:

root [1] DemoAnalyzer m
Warning in <TStreamerInfo::BuildCheck>:
   The StreamerInfo of class GenParticle read from file DrellYan.root
   has the same version (=2) as the active class but a different checksum.
   You should update the version to ClassDef(GenParticle,3).
   Do not try to write objects with the current class definition,
   the files will not be readable.

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'GenParticle' is missing from
the on-file layout version 2:
   float CtgTheta; //
Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'GenParticle' is missing from
the on-file layout version 2:
   float D0; //
Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'GenParticle' is missing from
the on-file layout version 2:
   float DZ; //
Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'GenParticle' is missing from
the on-file layout version 2:
   float T; //number
Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'GenParticle' is missing from
the on-file layout version 2:
   float X; //number
Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'GenParticle' is missing from
the on-file layout version 2:
   float Y; //number
Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'GenParticle' is missing from
the on-file layout version 2:
   float Z; //number
(DemoAnalyzer &) @0x7fc284bd1000
root [2] m.Loop()
******START EVENT LOOP!******    ,    Event nb = 0
start loop overall loose muons
end loop overall loose muons
******START EVENT LOOP!******    ,    Event nb = 1
start loop overall loose muons
end loop overall loose muons
******START EVENT LOOP!******    ,    Event nb = 2
start loop overall loose muons
end loop overall loose muons
******START EVENT LOOP!******    ,    Event nb = 3
start loop overall loose muons
end loop overall loose muons
******START EVENT LOOP!******    ,    Event nb = 4
start loop overall loose muons
end loop overall loose muons
******START EVENT LOOP!******    ,    Event nb = 5
start loop overall loose muons
end loop overall loose muons
******START EVENT LOOP!******    ,    Event nb = 6
start loop overall loose muons
end loop overall loose muons
******START EVENT LOOP!******    ,    Event nb = 7
start loop overall loose muons
end loop overall loose muons
******START EVENT LOOP!******    ,    Event nb = 8
start loop overall loose muons
end loop overall loose muons
******START EVENT LOOP!******    ,    Event nb = 9
start loop overall loose muons
end loop overall loose muons
Loop Ends!
Writing Histograms!
Writing Histograms ends!
write output file ends!
ROOT file: 0x5602df70a1e0has been created sucessfully!

The warnings in TStreamerInfo could be problematic if you do I/O of GenParticle, but they might also be due to me using a ROOT version that’s not compatible with the latest Delphes version, I don’t know.

If you are still experiencing a crash, or if there are still warnings or errors that you want to clarify, please share all code and files that are needed to reproduce them.

Cheers,
Enrico