Root crash when trying to quit root

Dear Rooters

Yesterday I have downloaded the new cvs version of root and recompiled
my libraries w/o making any changes.

After starting root and loading my libraries I started a macro to create
and fill a new root file where I store trees and also objects derived from my
own classes (which are inherited from TNamed). Everything seems to work fine,
the root file is created and filled and afterwards all my destructors are called.

However, everytime I try to quit root (.q) then root crashes beyond recovery.
I have to kill root explicitely. The crash reporter of MacOS X displays:

Thread 0 Crashed:
#0 0x0360de14 in 0x360de14
#1 0x01b2ecc4 in TClass::SetUnloaded() (TClass::SetUnloaded() + 48)
#2 0x01b09b4c in ROOT::RemoveClass(char const*) (ROOT::RemoveClass(char const*) + 128)
#3 0x035bc410 in G__cpp_setupXPSDataDict (G__cpp_setupXPSDataDict + 1324)
#4 0x9002c8b8 in exit (exit + 88)
#5 0x01b7bdc4 in TUnixSystem::Exit(int, bool) (TUnixSystem::Exit(int, bool) + 184)
#6 0x01a9408c in TApplication::ProcessLine(char const*, bool, int*) (TApplication::ProcessLine(char const*, bool, int*) + 424)
#7 0x00206fb8 in TRint::HandleTermInput() (TRint::HandleTermInput() + 572)
#8 0x01b7a7ec in TUnixSystem::CheckDescriptors() (TUnixSystem::CheckDescriptors() + 328)
#9 0x01b797d0 in TUnixSystem::DispatchOneEvent(bool) (TUnixSystem::DispatchOneEvent(bool) + 344)
#10 0x01ae9550 in TSystem::InnerLoop() (TSystem::InnerLoop() + 52)
#11 0x01ae94bc in TSystem::Run() (TSystem::Run() + 152)
#12 0x01a950e8 in TApplication::Run(bool) (TApplication::Run(bool) + 68)
#13 0x00206978 in TRint::Run(bool) (TRint::Run(bool) + 992)
#14 0x000021a8 in main (main + 124)
#15 0x00001e5c in _start (crt.c:267)
#16 0x00001cd0 in start (start + 48)

PPC Thread State:
srr0: 0x0360de14 srr1: 0x0008f930 vrsave: 0x00000000
cr: 0x42002224 xer: 0x20000004 lr: 0x03608fb4 ctr: 0x0360de14
r0: 0x03608fb4 r1: 0xbfffe9b0 r2: 0x036330c8 r3: 0x02d50160
r4: 0x00000003 r5: 0x04167350 r6: 0x021cfb90 r7: 0x04167350
r8: 0x021cf420 r9: 0x04167350 r10: 0xbfffea10 r11: 0x03636640
r12: 0x0360de14 r13: 0x00000000 r14: 0x00000000 r15: 0x00000000
r16: 0x00000000 r17: 0x00000000 r18: 0x00000000 r19: 0x00000000
r20: 0x00000000 r21: 0xbffff150 r22: 0x00000001 r23: 0x00000000
r24: 0x0217b310 r25: 0x00000001 r26: 0x00000000 r27: 0x00000000
r28: 0x02d4fe10 r29: 0x02d4fe28 r30: 0x04167350 r31: 0x01b09adc

When I look at the code of TClass::SetUnloaded() I see that the
following statement is added since my last version: delete fIsA;
Could this be the reason for the crash?

P.S.: For my purposes I needed to create a class XFolder: public TFolder,
where I store objects derived from my own classes.
Do I need to add a method TClass::IsA()?

Best regards
Christian

[quote]I needed to create a class XFolder: public TFolder,
where I store objects derived from my own classes.
Do I need to add a method TClass::IsA()? [/quote]
Not per se, but you need to had a ClassDef(XFolder,…);
and a dictionary for XFolder.

[quote]I see that the following statement is added since my last version: delete fIsA;[/quote]This is where the stack trace is indeed point to …
Could you send me an example reproducing the problem?

Cheers,
Philippe

Dear Philippe

Please find attached an example reproducing the problem.

The root output is:
root [0] .L macroMyClassA.C
root [1] Init()
root [2] Test()
MyClassA: fString = MyTest
root [3] TBrowser b
root [4] .q

*** Break *** illegal instruction
Root >

The corresponding output of the crash reporter of MacOS X 10.3.1 is:

Thread 0 Crashed:
#0 0x007bc03c in G__MyClassADictLN_TString (G__MyClassADictLN_TString + 0)
#1 0x007af460 in 0x7af460
#2 0x01b2ecc4 in TClass::SetUnloaded() (TClass::SetUnloaded() + 48)
#3 0x01b09b4c in ROOT::RemoveClass(char const*) (ROOT::RemoveClass(char const*) + 128)
#4 0x0076b6d0 in G__cpp_setupMyClassADict (G__cpp_setupMyClassADict + 148)
#5 0x9002c8b8 in exit (exit + 88)
#6 0x01b7bdc4 in TUnixSystem::Exit(int, bool) (TUnixSystem::Exit(int, bool) + 184)
#7 0x01a9408c in TApplication::ProcessLine(char const*, bool, int*) (TApplication::ProcessLine(char const*, bool, int*) + 424)
#8 0x00206fb8 in TRint::HandleTermInput() (TRint::HandleTermInput() + 572)
#9 0x01b7a7ec in TUnixSystem::CheckDescriptors() (TUnixSystem::CheckDescriptors() + 328)
#10 0x01b797d0 in TUnixSystem::DispatchOneEvent(bool) (TUnixSystem::DispatchOneEvent(bool) + 344)
#11 0x01ae9550 in TSystem::InnerLoop() (TSystem::InnerLoop() + 52)
#12 0x01ae94bc in TSystem::Run() (TSystem::Run() + 152)
#13 0x01a950e8 in TApplication::Run(bool) (TApplication::Run(bool) + 68)
#14 0x00206978 in TRint::Run(bool) (TRint::Run(bool) + 992)
#15 0x000021a8 in main (main + 124)
#16 0x00001e5c in _start (crt.c:267)
#17 0x00001cd0 in start (start + 48)

PPC Thread State:
srr0: 0x007bc03c srr1: 0x0008f930 vrsave: 0x00000000
cr: 0x22002248 xer: 0x20000004 lr: 0x007af460 ctr: 0x007bc03c
r0: 0x007af460 r1: 0xbfffe970 r2: 0x8fe507cc r3: 0x02d449e0
r4: 0x00000003 r5: 0x02d493c0 r6: 0x021cfb90 r7: 0x02d493c0
r8: 0x021cf420 r9: 0x02d493c0 r10: 0xbfffe9d0 r11: 0x007c9608
r12: 0x007bc03c r13: 0x00000000 r14: 0x00000000 r15: 0x00000000
r16: 0x00000000 r17: 0x00000000 r18: 0x00000000 r19: 0x00000000
r20: 0x00000000 r21: 0xbffff110 r22: 0x00000001 r23: 0x00000000
r24: 0x0217b310 r25: 0x00000001 r26: 0x00000000 r27: 0x00000000
r28: 0x02d40940 r29: 0x02d4095c r30: 0x02d493c0 r31: 0x01b09adc

Please note that I did not see this problem with earlier versions
of root including the cvs version 5.01/01 from May 6 2005.

Best regards
Christian
MyClassA.tar.gz (1.83 KB)

[quote]Please note that I did not see this problem with earlier versions
of root including the cvs version 5.01/01 from May 6 2005.
[/quote]I downloaded you example and ran it without any problem on a Mac.
(Darwin btwo.fnal.gov 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30 20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC Power Macintosh powerpc) with gcc 3.3
and with the latest code in ROOT.
Did you make sure to recompile each the file .o files and library with the newest version of ROOT?

Philippe.

Since I keep the last version(s) of root, I am always compiling the newest
cvs versions from scratch.
Which version of MacOS X did you use to test the code?

Best regards
Christian

Christian,

For MacOS I gave you all the information I know:

uname -a
Darwin btwo.fnal.gov 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30 20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC Power Macintosh powerpc

[quote] I am always compiling the newest cvs versions from scratch. [/quote]I meant the library MyClassA needs to be also recompile!

Philippe.

I have created this example after you have asked me to send you an
example, this means that it is completely new!
Christian

Humm … so something weird is going on? Which MacOS are your using? Which gcc? Also you have the line

Does it make a difference wethere it is there or not?
Do you do something in the graphical interface?

Philippe

I am using MacOS X 10.3.1 (7C107), Kernel version 7.0.0,
and gcc version 3.3 20030304 (Apple Computer, Inc. build 1495)
Furthermore, I am using Fink 0.16.2-1

At first I thought that TBrowser may be the cause, but omitting TBrowser
results in the same crash. I do not do anything in the graphical interface.
As I said, version 5.01/01 from May 6 did not cause any problems.

Regards
Christian

Unfortunately I have tried your example with a relatively close configuration (and the head of ROOT cvs repository as of today) and can not reproduce the problem :frowning:
So I’ll need your help in debugging the problem …
You’ll need to make sure you have a version of ROOT Build in debug mode
(for example rm /src/.o; make ROOTBUILD=debug)
Regenerate the file in your example in debug mode (replace the -O by -g in you makefile) and run the example in the debugger:

gdb root.exe gdb> run -b -l root [0] .L macroMyClassA.C root [1] Init() root [2] Test() MyClassA: fString = MyTest root [3] .q
then you should get a segmentation fault and you can do

This should match the stack trace your sent. It should also tell you which line of code it failed on. do a

gdb> print varnamefor each of the variable on the line
then do

and print each of the variable on the source line
and do one more

and print each of the variable on the source line.
Then do

gdb> print fIsA gdb> print *fIsA


and then me all the output!

Cheers,
Philippe.

I have now compiled root indebug mode (which took more than 2 hrs on my
Powerbook), changed the makefile and tried to run my program. Sorrowly,
I get the following error:

Christians-Computer:~/ROOT/rootcode/MyClassA rabbitus$ make -f Makefile4MyClassA
c++ -g -pipe -Wall -D_REENTRANT -Wno-long-double -I/sw/include -I/Users/rabbitus/ROOT/root/include -c MyClassA.cxx
Generating dictionary MyClassADict.cxx...
c++ -g -pipe -Wall -D_REENTRANT -Wno-long-double -I/sw/include -I/Users/rabbitus/ROOT/root/include -c MyClassADict.cxx
c++ -dynamiclib -flat_namespace -undefined suppress MyClassA.o MyClassADict.o -o  libMyClassA.dylib
c++ -bundle -undefined suppress -Wl,-x -g -Xlinker -bind_at_load -flat_namespace MyClassA.o MyClassADict.o \
           -o  libMyClassA.so
Christians-Computer:~/ROOT/rootcode/MyClassA rabbitus$ gdb root.exe
GNU gdb 5.3-20030128 (Apple version gdb-292) (Sat Sep 20 03:22:27 GMT 2003)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin".
Reading symbols for shared libraries ........... done
(gdb) run -b -l
Starting program: /Users/rabbitus/ROOT/root/bin/root.exe -b -l
Reading symbols for shared libraries warning: Trying to remove a section from the ordered section list that did not exist at 0x0.
+++++++++.... done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
root [0] .L macroMyClassA.C
root [1] Init()            
Reading symbols for shared libraries bfd_mach_o_scan_read_symtab_symbol: unable to read 12 bytes at 417104
. done

Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/operand.
0x002bff20 in ZN8MyClassAC1Ev.eh ()
(gdb) Test()
Undefined command: "Test".  Try "help".
(gdb) quit
The program is running.  Exit anyway? (y or n) y
Christians-Computer:~/ROOT/rootcode/MyClassA rabbitus$

Maybe, these messages give you a hint?

Regards
Christian

[quote]Maybe, these messages give you a hint? [/quote]Not yet. Instead of quitting the gdb session at the end you’ll need to follow the instruction in my previous post starting from typing ‘where’ at the gdb prompt

Philippe

Here is the output, but wouldn’t it be better to simply download the newest
cvs version of root?

Starting program: /Users/rabbitus/ROOT/root/bin/root.exe -b -l
Reading symbols for shared libraries warning: Trying to remove a section from the ordered section list that did not exist at 0x0.
+++++++++.... done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
root [0] .L macroMyClassA.C
root [1] Init()            
Reading symbols for shared libraries bfd_mach_o_scan_read_symtab_symbol: unable to read 12 bytes at 417104
. done

Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/operand.
0x002bff20 in ZN8MyClassAC1Ev.eh ()
(gdb) Test()
Undefined command: "Test".  Try "help".
(gdb) where
#0  0x002bff20 in ZN8MyClassAC1Ev.eh ()
#1  0x00277f8c in ROOT::GenerateInitInstance(MyClassA const*) ()
#2  0x002bdc68 in dyld_stub_wmemcpy ()
#3  0x002bdcf4 in dyld_stub_wmemcpy ()
#4  0x8fe17b38 in __dyld_call_module_initializers_for_objects ()
#5  0x8fe17600 in __dyld_call_module_initializers ()
#6  0x8fe118ac in __dyld_link_in_need_modules ()
#7  0x8fe134e4 in __dyld__dyld_link_module ()
#8  0x9003f5a8 in NSLinkModule ()
#9  0x900f86ec in loadModule ()
#10 0x900f8a74 in dlopen ()
#11 0x011066a4 in G__dlopen (path=0x12d27c6 "/Users/rabbitus/ROOT/rootcode/MyClassA/./libMyClassA.so") at cint/src/shl.c:239
#12 0x0110725c in G__shl_load (shlfile=0x12d27c6 "/Users/rabbitus/ROOT/rootcode/MyClassA/./libMyClassA.so") at cint/src/shl.c:912
#13 0x0108d810 in G__loadfile (filenamein=0x16134d0 "/Users/rabbitus/ROOT/rootcode/MyClassA/./libMyClassA.so") at cint/src/loadfile.c:2307
#14 0x03607c40 in TCint::Load(char const*, bool) (this=0x609ea0, filename=0x16134d0 "/Users/rabbitus/ROOT/rootcode/MyClassA/./libMyClassA.so", system=false) at meta/src/TCint.cxx:269
#15 0x035b4670 in TSystem::Load(char const*, char const*, bool) (this=0x6047f0, module=0x900040c "libMyClassA.so", entry=0x3aa7b68 "", system=false) at base/src/TSystem.cxx:1426
#16 0x03675600 in TUnixSystem::Load(char const*, char const*, bool) (this=0x6047f0, module=0x900040c "libMyClassA.so", entry=0x3aa7b68 "", system=false) at unix/src/TUnixSystem.cxx:2165
#17 0x0383a168 in G__G__Base2_258_1_10(G__value*, char const*, G__param*, int) () at /usr/include/gcc/darwin/3.3/c++/bits/basic_string.h:1123
#18 0x01095c98 in G__call_cppfunc (result7=0xbffdfa60, libp=0xbffe02b0, ifunc=0xa55fe00, ifn=1) at cint/src/newlink.c:576
#19 0x010791e0 in G__interpret_func (result7=0xbffdfa60, funcname=0xbffdfa80 "Load", libp=0xbffe02b0, hash=384, p_ifunc=0xa55fe00, funcmatch=1, memfunc_flag=1) at cint/src/ifunc.c:6946
#20 0x0104b9f4 in G__getfunction (item=0xbffe4349 "Load(\"libMyClassA.so\")", known3=0xbffe4c80, memfunc_flag=1) at cint/src/func.c:3367
#21 0x0114f314 in G__getstructmem (store_var_type=112, varname=0xbffe35e0 "", membername=0xbffe4349 "Load(\"libMyClassA.so\")", tagname=0xbffe4340 "gSystem", known2=0xbffe4c80, varglobal=0x12496b4, objptr=2) at cint/src/var.c:5170
#22 0x01140b90 in G__getvariable (item=0xbffe5f30 "gSystem->Load(\"libMyClassA.so\")", known2=0xbffe4c80, varglobal=0x12496b4, varlocal=0xbffe6d30) at cint/src/var.c:3722
#23 0x01039660 in G__getitem (item=0xbffe5f30 "gSystem->Load(\"libMyClassA.so\")") at cint/src/expr.c:2381
#24 0x01036e18 in G__getexpr (expression=0xbffe6750 "gSystem->Load(\"libMyClassA.so\")") at cint/src/expr.c:1713
#25 0x010be35c in G__exec_function (statement=0xbffe6750 "gSystem->Load(\"libMyClassA.so\")", pc=0xbffe6b50, piout=0xbffe6b5c, plargestep=0xbffe6b6c, presult=0xbffe6730) at cint/src/parse.c:548
#26 0x010cbcd4 in G__exec_statement () at cint/src/parse.c:4925
#27 0x0107c110 in G__interpret_func (result7=0xbfff0130, funcname=0xbfff0150 "Init", libp=0xbfff0980, hash=404, p_ifunc=0xa530c00, funcmatch=1, memfunc_flag=0) at cint/src/ifunc.c:7963
#28 0x0104c680 in G__getfunction (item=0xbfff4e60 "Init()", known3=0xbfff3bb0, memfunc_flag=0) at cint/src/func.c:3687
#29 0x01039694 in G__getitem (item=0xbfff4e60 "Init()") at cint/src/expr.c:2385
#30 0x01036e18 in G__getexpr (expression=0xbfff5680 "Init()") at cint/src/expr.c:1713
#31 0x010be35c in G__exec_function (statement=0xbfff5680 "Init()", pc=0xbfff5a80, piout=0xbfff5a8c, plargestep=0xbfff5a9c, presult=0xbfff5660) at cint/src/parse.c:548
#32 0x010cbcd4 in G__exec_statement () at cint/src/parse.c:4925
#33 0x0100f2f8 in G__exec_tempfile_core (file=0x0, fp=0xa538e0c) at cint/src/debug.c:390
#34 0x0100f65c in G__exec_tempfile_fp (fp=0xa538e0c) at cint/src/debug.c:476
#35 0x010d8b94 in G__process_cmd (line=0x161337c "Init()", prompt=0x609ec4 "", more=0x609ebc, err=0xbfffea70, rslt=0xbfffea50) at cint/src/pause.c:4252
#36 0x03607e10 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) (this=0x609ea0, line=0x161337c "Init()", error=0x0) at meta/src/TCint.cxx:310
#37 0x0352ce68 in TApplication::ProcessLine(char const*, bool, int*) (this=0x6868f0, line=0x161337c "Init()", sync=false, err=0x0) at base/src/TApplication.cxx:701
#38 0x0038b938 in TRint::HandleTermInput() (this=0x6868f0) at rint/src/TRint.cxx:415
#39 0x0038a2d8 in TTermInputHandler::Notify() (this=0x160f6b0) at rint/src/TRint.cxx:102
#40 0x003eb9cc in TTermInputHandler::ReadNotify() (this=0x160f6b0) at rint/src/TRint.cxx:96
#41 0x03673368 in TUnixSystem::CheckDescriptors() (this=0x6047f0) at unix/src/TUnixSystem.cxx:995
#42 0x03672450 in TUnixSystem::DispatchOneEvent(bool) (this=0x6047f0, pendingOnly=false) at unix/src/TUnixSystem.cxx:712
#43 0x035b0cf8 in TSystem::InnerLoop() (this=0x6047f0) at base/src/TSystem.cxx:316
#44 0x035b0c1c in TSystem::Run() (this=0x6047f0) at base/src/TSystem.cxx:284
#45 0x0352d8bc in TApplication::Run(bool) (this=0x6868f0, retrn=false) at base/src/TApplication.cxx:830
#46 0x0038b08c in TRint::Run(bool) (this=0x6868f0, retrn=false) at rint/src/TRint.cxx:274
#47 0x000020d4 in main (argc=1, argv=0xbffffd7c) at main/src/rmain.cxx:29
(gdb) print varname
No symbol "varname" in current context.
(gdb) print theApp
No symbol "theApp" in current context.
(gdb) print handle
No symbol "handle" in current context.
(gdb) 

Regards
Christian

[quote]Here is the output, but wouldn’t it be better to simply download the newest[/quote]I assume that you did! (while the latest ROOT I could NOT reproduce your problem)

code where
#0 0x002bff20 in ZN8MyClassAC1Ev.eh ()
#1 0x00277f8c in ROOT::GenerateInitInstance(MyClassA const*) ()[/code]This tells me that your library was not built debug … Could rebuild it in debug mode and try again?
Thanks,
Philippe.

In the attached makefile I replaced the -O by -g as you suggested and
called make -f Makefile4MyClassA.
Is this correct?
Christian

P.S. I Attached Makefile4MyClassA.txt since Makefile4MyClassA is not allowed
Makefile4MyClassA.txt (2.08 KB)

[quote]n the attached makefile I replaced the -O by -g as you suggested[/quote]Yes this should have been sufficient

[quote] and called make -f Makefile4MyClassA. [/quote]I assume that you also first deleted the existing .o, .dylib and .so files.

Philippe.

Yes, I am always deleting all files which are not my source files.
Christian

Then I have no clue what’s going on :frowning: If possible send me (privately) information on how to log into your MacOS machine and reproduce the problem!

Philippe.

At the moment I will download the new cvs version and see if the problem remains. I let you know.

Thank you for your efforts
Christian

Sorrowly, the newest version, which took 3 hrs to compile, still has the same problem.
Maybe, my version of MacOS X is already too old?

Regards
Christian