Segmentation violation when using gROOT->ProcessLine()

Dear experts,

When calling gROOT->ProcessLine() a segmentation violation occurs. I am using ROOT version 6.12/06. I have seen there was a bug in previous ROOT versions but not sure why it is still happening to me.

The command I am trying to run is 'gROOT->ProcessLine(".x ~/lhcbStyle.C").

Below is my minimal working example:

#include <iostream>

#include <TROOT.h>

using namespace std;

int main(int argc, char* argv[]) {

gROOT->ProcessLine(".x ~/lhcbStyle.C");

std::cout << "LHCb Style" << std::endl;

return 0;

}

I compile using the command:

g++ $(root-config --cflags) min_example.cpp -o D0MassFit_BDT $(root-config --libs) -lRooFitCore -lRooFit

ROOT: 6.12/06
Platform: x86_64-slc6-gcc62-opt
Compiler: g++ (GCC) 6.2.0

I have copied the stack trace below. Many thanks in advance for your help.

Martha

*** Break *** segmentation violation

===========================================================

There was a crash.

This is the entire stack trace of all threads:

===========================================================

#0 0x00007f562235689e in waitpid () from /lib64/libc.so.6

#1 0x00007f56222e84e9 in do_system () from /lib64/libc.so.6

#2 0x00007f56273f5568 in TUnixSystem::StackTrace() () from /cvmfs/sft.cern.ch/lcg/views/LCG_93python3/x86_64-slc6-gcc62-opt/lib/libCore.so

#3 0x00007f56273f7a6c in TUnixSystem::DispatchSignals(ESignals) () from /cvmfs/sft.cern.ch/lcg/views/LCG_93python3/x86_64-slc6-gcc62-opt/lib/libCore.so

#4 <signal handler called>

#5 std::ostream::sentry::sentry (this=0x7fff2f07dc00, __os=...) at /mnt/build/jenkins/workspace/lcg_contrib_release/LABEL/slc6/build/contrib/gcc-6.2.0/src/gcc-6.2.0-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/ostream.tcc:51

#6 0x00007f5622e021c9 in std::__ostream_insert<char, std::char_traits<char> > (__out=..., __s=__s

entry=0x7f562798b0fb '-' <repeats 25 times>, __n=25) at /mnt/build/jenkins/workspace/lcg_contrib_release/LABEL/slc6/build/contrib/gcc-6.2.0/src/gcc-6.2.0-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/ostream_insert.h:82

#7 0x00007f5622e02627 in std::operator<< <std::char_traits<char> > (__out=..., __s=0x7f562798b0fb '-' <repeats 25 times>) at /mnt/build/jenkins/workspace/lcg_contrib_release/LABEL/slc6/build/contrib/gcc-6.2.0/src/gcc-6.2.0-build/x86_64-pc-linux-gnu/libstdc++-v3/include/ostream:561

#8 0x00007f562798d992 in ?? ()

#9 0x0000000000000016 in ?? ()

#10 0x0000000002510ff0 in ?? ()

#11 0x00007fff2f07dd50 in ?? ()

#12 0x00000000025ba940 in ?? ()

#13 0x0000000000000000 in ?? ()

===========================================================

The lines below might hint at the cause of the crash.

You may get help by asking at the ROOT forum http://root.cern.ch/forum.

Only if you are really convinced it is a bug in ROOT then please submit a

report at http://root.cern.ch/bugs. Please post the ENTIRE stack trace

from above as an attachment in addition to anything else

that might help us fixing this issue.

===========================================================

#5 std::ostream::sentry::sentry (this=0x7fff2f07dc00, __os=...) at /mnt/build/jenkins/workspace/lcg_contrib_release/LABEL/slc6/build/contrib/gcc-6.2.0/src/gcc-6.2.0-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/ostream.tcc:51

#6 0x00007f5622e021c9 in std::__ostream_insert<char, std::char_traits<char> > (__out=..., __s=__s

entry=0x7f562798b0fb '-' <repeats 25 times>, __n=25) at /mnt/build/jenkins/workspace/lcg_contrib_release/LABEL/slc6/build/contrib/gcc-6.2.0/src/gcc-6.2.0-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/ostream_insert.h:82

#7 0x00007f5622e02627 in std::operator<< <std::char_traits<char> > (__out=..., __s=0x7f562798b0fb '-' <repeats 25 times>) at /mnt/build/jenkins/workspace/lcg_contrib_release/LABEL/slc6/build/contrib/gcc-6.2.0/src/gcc-6.2.0-build/x86_64-pc-linux-gnu/libstdc++-v3/include/ostream:561

#8 0x00007f562798d992 in ?? ()

#9 0x0000000000000016 in ?? ()

#10 0x0000000002510ff0 in ?? ()

#11 0x00007fff2f07dd50 in ?? ()

#12 0x00000000025ba940 in ?? ()

#13 0x0000000000000000 in ?? ()

===========================================================

Hi Martha,

what is inside the macro?

D

Hi,

I have uploaded it, sorry I did not include this in my original post.

Thanks.

lhcbStyle.C (6.4 KB)

I tried it on my Mac. Seems ok:

$ root
   --------------------------------------------------------------------
  | Welcome to ROOT 6.15/01                        http://root.cern.ch |
  |                                       (c) 1995-2018, The ROOT Team |
  | Built for macosx64                                                 |
  | From heads/master@v6-13-04-1053-gf463d0cac4, Aug 30 2018, 09:20:55 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'         |
   --------------------------------------------------------------------

root [0] gROOT->ProcessLine(".x lhcbStyle.C");
-------------------------
Set LHCb Style - Feb 2012
-------------------------
root [1] 

In the “lhcbStyle.C”, try to comment out lines with “cout” (ROOT 6.08/06, 6.12/06 and 6.14/04 die without this “brutal fix”, while ROOT 6.10/08 and 5.34 run fine).

Note also that the very first line of a ROOT unnamed macro should contain just “{” (i.e. this should be the very first character of your file).

Hi all,

Thanks for the help. I tried commenting out the “cout” lines in “lhcbStyle.C” and it works.

However the segmentation violation occurs in the following example:

#include <iostream>
#include <TROOT.h>

using namespace std;

int main(int argc, char* argv[]) {

  //gROOT->ProcessLine(".x ~/lhcbStyle.C");                                                                                                               
  gROOT->ProcessLine("std::cout << \"Test\" << std::endl");

  std::cout << "LHCb Style" << std::endl;
  return 0;
}

so it looks like it was a problem with using “cout” within “gROOT->ProcessLine()”.

I compile with the following command:

g++ -pthread -std=c++1y -m64 -I/cvmfs/sft.cern.ch/lcg/releases/ROOT/6.12.06-6b444/x86_64-slc6-gcc62-opt/include min_example.cpp -o D0MassFit_BDT -L/cvmfs/sft.cern.ch/lcg/releases/ROOT/6.12.06-6b444/x86_64-slc6-gcc62-opt/lib -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -pthread -lm -ldl -rdynamic -lRooFitCore -lRooFit

Thank you.

If you need to print some message in your macro, using printf might be an working solution in that case.

For reference, there is a pre-existing JIRA task for this bug: ROOT-9324

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.