TPython::Exec() crashes on root imports

Dear ROOTers,

I am trying to call some of my pyROOT scripts from ROOT. I’ve encoutered a very simple issue. I can’t use TGraph, TH2D, etc., in a way that I am trying to, because ROOT crashes on:

TPython::Exec("from ROOT import TH2D")


TPython::Exec("import ROOT")
TPython::Exec("g = ROOT.TGraph()")

In the latter case, the crash is:

There was a crash.
This is the entire stack trace of all threads:
#0  0x00007f5e737218ba in waitpid () from /usr/lib64/
#1  0x00007f5e7369e4b7 in do_system () from /usr/lib64/
#2  0x00007f5e73e87b03 in TUnixSystem::Exec (shellcmd=<optimized out>, this=0x22ee800) at /opt/root-6.16.00_src/core/unix/src/TUnixSystem.cxx:2119
#3  TUnixSystem::StackTrace (this=0x22ee800) at /opt/root-6.16.00_src/core/unix/src/TUnixSystem.cxx:2413
#4  0x00007f5e73e8a2f4 in TUnixSystem::DispatchSignals (this=0x22ee800, sig=kSigSegmentationViolation) at /opt/root-6.16.00_src/core/unix/src/TUnixSystem.cxx:3644
#5  <signal handler called>
#6  0x0000000004a54610 in ?? ()
#7  0x00007f5e705f1417 in cling::Interpreter::unload(cling::Transaction&) () from /home/lewhoo/opt/root_6.16/lib/
#8  0x00007f5e705f157c in cling::Interpreter::unload(unsigned int) () from /home/lewhoo/opt/root_6.16/lib/
#9  0x00007f5e706b15a8 in cling::MetaSema::actOnUCommand(llvm::StringRef) () from /home/lewhoo/opt/root_6.16/lib/
#10 0x00007f5e706b1d8f in cling::MetaSema::actOnLCommand(llvm::StringRef, cling::Transaction**) () from /home/lewhoo/opt/root_6.16/lib/
#11 0x00007f5e706b2049 in cling::MetaSema::actOnxCommand(llvm::StringRef, llvm::StringRef, cling::Value*) () from /home/lewhoo/opt/root_6.16/lib/
#12 0x00007f5e706bfece in cling::MetaParser::isXCommand(cling::MetaSema::ActionResult&, cling::Value*) () from /home/lewhoo/opt/root_6.16/lib/
#13 0x00007f5e706c1056 in cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) () from /home/lewhoo/opt/root_6.16/lib/
#14 0x00007f5e706abc79 in cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) () from /home/lewhoo/opt/root_6.16/lib/
#15 0x00007f5e7055352c in HandleInterpreterException (metaProcessor=0x252ac90, input_line=0x42e2de0 ".X  /home/lewhoo/.rootlogon.C", compRes=
0x7ffd5a8f9114: cling::Interpreter::kSuccess, result=0x7ffd5a8f9240) at /opt/root-6.16.00_src/interpreter/llvm/src/include/llvm/ADT/StringRef.h:85
#16 0x00007f5e70567cd0 in TCling::ProcessLine (this=0x2361f10, line=<optimized out>, error=0x0) at /opt/root_6.16/include/TString.h:239
#17 0x00007f5e7055a5b7 in TCling::ProcessLineSynch (this=0x2361f10, line=0x4a3d380 ".X  /home/lewhoo/.rootlogon.C", error=0x0) at /opt/root-6.16.00_src/core/metacling/src/TCling.cxx:3168
#18 0x00007f5e73d4a8a5 in TApplication::ExecuteFile (file=<optimized out>, error=0x0, keep=<optimized out>) at /opt/root_6.16/include/TString.h:239
#19 0x00007f5e5b5ba06b in ?? ()
#20 0x00007ffd5a8fa070 in ?? ()
#21 0x0000000000000006 in ?? ()
#22 0x0000345f66635f5f in ?? ()
#23 0x00007ffd5a8fa1c0 in ?? ()
#24 0x00000000049b8cd0 in ?? ()
#25 0x000000000000045b in ?? ()
#26 0x000000000000045b in ?? ()
#27 0x0000000000000000 in ?? ()

What can I do to use ROOT classes in pyROOT called through Exec?

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.16
Platform: Fedora 29
Compiler: Not Provided

Interesting thing is that in ROOT samples executes properly, but calling directly from ROOT shell


causes segmentation fault.

Hi @LeWhoo,

@etejedor might be able to help.

Dear LeWhoo,

I can’t reproduce with ROOT master:

bash-4.2$ root -l
root [0] TPython::Exec("import ROOT")
(bool) true
root [1] TPython::Exec("g = ROOT.TGraph()")
(bool) true

Might be a problem with your installation? Could you try with master as well?

Thanks! I’ve tested with 6.18.04 and it works properly.

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