TPDF::Open:0: RuntimeWarning: PDF file already open

This is a rather strange issue. I’m having a really hard time tracking down WHAT is specifically causing this to occur.

I have a script which does something like the following

def save_plot(....):
  c = ROOT.TCanvas(....)
  t.Draw(....)
  c.Print("output.pdf", "Title:...")
  del c

def make_report(...):
  blankC = ROOT.TCanvas()
  blankC.Print("output.pdf[")
  for branch in t.GetListOfBranches():
    save_plot(branch, ...)
  blankC.Print("output.pdf]")

So basically, it loops over the branches, does a ttree draw, and adds each of that into the output.pdf file. Sometimes, this segfaults – with the following below (after successfully drawing 92 branches) and I don’t know why. There’s nothing special about the branch itself, and the branch order is shuffled… etc…

The first code block is the PyROOT exception catcher

--------------------
An exception was caught!
Traceback (most recent call last):
  File "/export/home/kratsg/xAODAnalysis/RootCoreBin/bin/x86_64-slc6-gcc48-opt/dumpSG.py", line 549, in <module>
    make_report(t, filtered_xAOD_Objects, directory=args.output_directory, merge_report=args.merge_report)
  File "/export/home/kratsg/xAODAnalysis/RootCoreBin/bin/x86_64-slc6-gcc48-opt/dumpSG.py", line 115, in wrapped
    return fn(*v, **k)
  File "/export/home/kratsg/xAODAnalysis/RootCoreBin/bin/x86_64-slc6-gcc48-opt/dumpSG.py", line 311, in make_report
    save_plot(pathToImage, item, container)
  File "/export/home/kratsg/xAODAnalysis/RootCoreBin/bin/x86_64-slc6-gcc48-opt/dumpSG.py", line 115, in wrapped
    return fn(*v, **k)
  File "/export/home/kratsg/xAODAnalysis/RootCoreBin/bin/x86_64-slc6-gcc48-opt/dumpSG.py", line 249, in save_plot
    c.Print(pathToImage, 'Title:{0}'.format(item['name']))
TypeError: none of the 2 overloaded methods succeeded. Full details:
  void TPad::Print(const char* filename = "") =>
    takes at most 1 arguments (2 given)
  problem in C++; program state has been reset

and the following is the ROOT output

TPDF::Open:0: RuntimeWarning: PDF file already open
 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00000033546ac61e in waitpid () from /lib64/libc.so.6
#1  0x000000335463e609 in do_system () from /lib64/libc.so.6
#2  0x00007f19f775ef1f in TUnixSystem::StackTrace() () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libCore.so
#3  0x00007f19f7760a8c in TUnixSystem::DispatchSignals(ESignals) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libCore.so
#4  <signal handler called>
#5  0x0000003354990088 in main_arena () from /lib64/libc.so.6
#6  0x00007f19f7700ab1 in TList::FindObject(char const*) const () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libCore.so
#7  0x00007f19f8b7a49b in TPad::Print(char const*, char const*) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libGpad.so
#8  0x00007f19f7581af1 in G__G__Base1_309_0_118(G__value*, char const*, G__param*, int) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libCore.so
#9  0x00007f19f6841feb in Cint::G__CallFunc::Execute(void*) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libCint.so
#10 0x00007f19fa4b7e36 in PyROOT::TVoidExecutor::Execute(Cint::G__CallFunc*, void*, bool) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libPyROOT.so
#11 0x00007f19fa4bf1f0 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::CallSafe(void*, bool) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libPyROOT.so
#12 0x00007f19fa4bf362 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::Execute(void*, bool) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libPyROOT.so
#13 0x00007f19fa4be7ab in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::operator()(PyROOT::ObjectProxy*, _object*, _object*, long, bool) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libPyROOT.so
#14 0x00007f19fa4a3266 in PyROOT::(anonymous namespace)::mp_call(PyROOT::MethodProxy*, _object*, _object*) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libPyROOT.so
#15 0x00007f1a02cee703 in PyObject_Call () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#16 0x00007f1a02da12a1 in PyEval_EvalFrameEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:4239
#17 0x00007f1a02da55ed in PyEval_EvalCodeEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:3253
#18 0x00007f1a02d201b5 in function_call () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#19 0x00007f1a02cee703 in PyObject_Call () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#20 0x00007f1a02da0976 in PyEval_EvalFrameEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:4334
#21 0x00007f1a02da55ed in PyEval_EvalCodeEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:3253
#22 0x00007f1a02da4ad5 in PyEval_EvalFrameEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:4117
#23 0x00007f1a02da55ed in PyEval_EvalCodeEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:3253
#24 0x00007f1a02d201b5 in function_call () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#25 0x00007f1a02cee703 in PyObject_Call () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#26 0x00007f1a02da0976 in PyEval_EvalFrameEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:4334
#27 0x00007f1a02da55ed in PyEval_EvalCodeEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:3253
#28 0x00007f1a02da4ad5 in PyEval_EvalFrameEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:4117
#29 0x00007f1a02da55ed in PyEval_EvalCodeEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:3253
#30 0x00007f1a02da5722 in PyEval_EvalCode () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:667
#31 0x00007f1a02dcfec2 in PyRun_FileExFlags () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#32 0x00007f1a02dd1409 in PyRun_SimpleFileExFlags () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#33 0x00007f1a02de6cfd in Py_Main () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#34 0x000000335461ed5d in __libc_start_main () from /lib64/libc.so.6
#35 0x00000000004006d9 in _start ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug 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  0x0000003354990088 in main_arena () from /lib64/libc.so.6
#6  0x00007f19f7700ab1 in TList::FindObject(char const*) const () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libCore.so
#7  0x00007f19f8b7a49b in TPad::Print(char const*, char const*) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libGpad.so
===========================================================



 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00000033546ac61e in waitpid () from /lib64/libc.so.6
#1  0x000000335463e609 in do_system () from /lib64/libc.so.6
#2  0x00007f19f775ef1f in TUnixSystem::StackTrace() () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libCore.so
#3  0x00007f19f7760a8c in TUnixSystem::DispatchSignals(ESignals) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libCore.so
#4  <signal handler called>
#5  0x0000003354990088 in main_arena () from /lib64/libc.so.6
#6  0x00007f19f7700ab1 in TList::FindObject(char const*) const () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libCore.so
#7  0x00007f19f8b7a49b in TPad::Print(char const*, char const*) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libGpad.so
#8  0x00007f19f7581af1 in G__G__Base1_309_0_118(G__value*, char const*, G__param*, int) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libCore.so
#9  0x00007f19f6841feb in Cint::G__CallFunc::Execute(void*) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libCint.so
#10 0x00007f19fa4b7e36 in PyROOT::TVoidExecutor::Execute(Cint::G__CallFunc*, void*, bool) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libPyROOT.so
#11 0x00007f19fa4bf1f0 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::CallSafe(void*, bool) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libPyROOT.so
#12 0x00007f19fa4bf362 in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::Execute(void*, bool) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libPyROOT.so
#13 0x00007f19fa4be7ab in PyROOT::TMethodHolder<PyROOT::TScopeAdapter, PyROOT::TMemberAdapter>::operator()(PyROOT::ObjectProxy*, _object*, _object*, long, bool) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libPyROOT.so
#14 0x00007f19fa4a341a in PyROOT::(anonymous namespace)::mp_call(PyROOT::MethodProxy*, _object*, _object*) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libPyROOT.so
#15 0x00007f1a02cee703 in PyObject_Call () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#16 0x00007f1a02da12a1 in PyEval_EvalFrameEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:4239
#17 0x00007f1a02da55ed in PyEval_EvalCodeEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:3253
#18 0x00007f1a02d201b5 in function_call () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#19 0x00007f1a02cee703 in PyObject_Call () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#20 0x00007f1a02da0976 in PyEval_EvalFrameEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:4334
#21 0x00007f1a02da55ed in PyEval_EvalCodeEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:3253
#22 0x00007f1a02da4ad5 in PyEval_EvalFrameEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:4117
#23 0x00007f1a02da55ed in PyEval_EvalCodeEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:3253
#24 0x00007f1a02d201b5 in function_call () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#25 0x00007f1a02cee703 in PyObject_Call () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#26 0x00007f1a02da0976 in PyEval_EvalFrameEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:4334
#27 0x00007f1a02da55ed in PyEval_EvalCodeEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:3253
#28 0x00007f1a02da4ad5 in PyEval_EvalFrameEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:4117
#29 0x00007f1a02da55ed in PyEval_EvalCodeEx () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:3253
#30 0x00007f1a02da5722 in PyEval_EvalCode () at /build/hegner/afs_build/lcgcmake-build/externals/Python/src/Python/2.7.4/Python/ceval.c:667
#31 0x00007f1a02dcfec2 in PyRun_FileExFlags () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#32 0x00007f1a02dd1409 in PyRun_SimpleFileExFlags () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#33 0x00007f1a02de6cfd in Py_Main () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/python/2.7.4-x86_64-slc6-gcc48/sw/lcg/external/Python/2.7.4/x86_64-slc6-gcc48-opt/bin/../lib/libpython2.7.so.1.0
#34 0x000000335461ed5d in __libc_start_main () from /lib64/libc.so.6
#35 0x00000000004006d9 in _start ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug 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  0x0000003354990088 in main_arena () from /lib64/libc.so.6
#6  0x00007f19f7700ab1 in TList::FindObject(char const*) const () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libCore.so
#7  0x00007f19f8b7a49b in TPad::Print(char const*, char const*) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/lib/libGpad.so
===========================================================

This is so random, I think I need to file a JIRA issue. I know exactly what causes it to crash:

c.Print("output.pdf", "Title:Vertex")
c.Print("output.pdf", "Title:vertex")
...

and all case-insensitive variants of it.

This is verified to be reproducible

import ROOT
c = ROOT.TCanvas()
c.Print("output.pdf[")
c.Print("output.pdf", "Title:Vertex")
c.Print("output.pdf]")

JIRA: sft.its.cern.ch/jira/browse/ROOT-7087

Now fixed.