THStack segfaults when constructed from TH3D

Dear all!

I tried both ROOT 5.30.05 and 5.34.05 on lxplus and both versions crash executing the following:

TFile* f = TFile::Open("stack_segfault.root");
TH3D* h = (TH3D*)f->Get("ClustEtaElecWeightVsDeltaPhi");
THStack* stack = new THStack(h, "zy");
/afs/cern.ch/user/s/schmitts/public/stack_segfault/stack_segfault.root

You can find the full stack trace below.

Do I do something wrong or is there a bug?

Thanks,

Sebastian

Processing stack_segfault.C...

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007fe95dd5443e in __libc_waitpid (pid=<optimized out>, stat_loc=0x7fffa9bfe400, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:32
#1  0x00007fe95dcda29e in do_system (line=0x28529c0 "/etc/root/gdb-backtrace.sh 14420 1>&2") at ../sysdeps/posix/system.c:149
#2  0x00007fe95ec13327 in TUnixSystem::StackTrace() () from /usr/local/lib/root/libCore.so
#3  0x00007fe95ec15c03 in TUnixSystem::DispatchSignals(ESignals) () from /usr/local/lib/root/libCore.so
#4  <signal handler called>
#5  0x00007fe95ad274b6 in TH3::Project3D(char const*) const () from /usr/local/lib/root/libHist.so
#6  0x00007fe95ad39eff in THStack::THStack(TH1 const*, char const*, char const*, char const*, int, int, int, int, char const*, char const*) () from /usr/local/lib/root/libHist.so
#7  0x00007fe95aea5048 in G__G__Hist_366_0_5(G__value*, char const*, G__param*, int) () from /usr/local/lib/root/libHist.so
#8  0x00007fe95cf09aab in Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) () from /usr/local/lib/root/libCint.so
#9  0x00007fe95cfaf3e1 in G__execute_call () from /usr/local/lib/root/libCint.so
#10 0x00007fe95cfaf7ce in G__call_cppfunc () from /usr/local/lib/root/libCint.so
#11 0x00007fe95cf90177 in G__interpret_func () from /usr/local/lib/root/libCint.so
#12 0x00007fe95cf7c646 in G__getfunction () from /usr/local/lib/root/libCint.so
#13 0x00007fe95cfacd4f in G__new_operator () from /usr/local/lib/root/libCint.so
#14 0x00007fe95cf5c292 in G__getexpr () from /usr/local/lib/root/libCint.so
#15 0x00007fe95cf497c8 in G__define_var () from /usr/local/lib/root/libCint.so
#16 0x00007fe95cfdc74e in G__exec_statement () from /usr/local/lib/root/libCint.so
#17 0x00007fe95cfa5e35 in G__loadfile () from /usr/local/lib/root/libCint.so
#18 0x00007fe95cfef678 in G__process_cmd () from /usr/local/lib/root/libCint.so
#19 0x00007fe95ebdd54a in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /usr/local/lib/root/libCore.so
#20 0x00007fe95ebd3f33 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /usr/local/lib/root/libCore.so
#21 0x00007fe95eb43414 in TApplication::ExecuteFile(char const*, int*, bool) () from /usr/local/lib/root/libCore.so
#22 0x00007fe95eb4214f in TApplication::ProcessLine(char const*, bool, int*) () from /usr/local/lib/root/libCore.so
#23 0x00007fe95e7997fa in TRint::Run(bool) () from /usr/local/lib/root/libRint.so
#24 0x0000000000400f6c in main ()
===========================================================


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  0x00007fe95ad274b6 in TH3::Project3D(char const*) const () from /usr/local/lib/root/libHist.so
#6  0x00007fe95ad39eff in THStack::THStack(TH1 const*, char const*, char const*, char const*, int, int, int, int, char const*, char const*) () from /usr/local/lib/root/libHist.so
===========================================================

THStack is a container for TH! and TH2. For instance there is no way to draw a THStack made of TH3 .

Hi!

I understand, but I was referring to this c’tor:

http://root.cern.ch/root/html/THStack.html#THStack:THStack@2

 Creates a new THStack from a TH2 or TH3
 It is filled with the 1D histograms from GetProjectionX or GetProjectionY
 for each bin of the histogram.

Thanks,

Sebastian

Hi!

There is a problem with the name of the histogram. When I first set the title and the name to “foo”, the construction, i.e. the Project3D, works.

Cheers,

Sebastian

Hi,
The problem appeared because the histogram name contains a “d” which enables the “d” (draw the projected histogram) option. I will fix later the problem with the option, conflicting histogram name and drawing option.

The crash was actually due to a missing check on the global pad (gPad). The problem was present also in other projection routines (e.g. TH2::ProfileX/Y). This is now fixed in the trunk and 5.34 patches.

Thank you for reporting this problem,

Lorenzo