ROOT Gui problem

Hi,

I have a ROOT Gui. It is not standalone but It is in one big Cint macro file. It works as it is and does the job.
But when I just start it and immediately exit from the Gui (so it doesn’t do anything but just creating the Gui itself and exit) I get this message:

root [1] *** glibc detected *** /usr/local/src/root/bin/root.exe: free(): invalid next size (fast): 0x08520a20 ***
======= Backtrace: =========
/lib/libc.so.6[0xb72094b6]
/lib/libc.so.6(cfree+0x89)[0xb720b179]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb73d7a61]
/usr/local/src/root/lib/libCint.so(_ZNSt8_Rb_treeI14G__ifunc_tableS0_St9_IdentityIS0_ESt4lessIS0_ESaIS0_EE8_M_eraseEPSt13_Rb_tree_nodeIS0_E+0x3d)[0xb756ae3d]
/usr/local/src/root/lib/libCint.so(_ZNSt8_Rb_treeI14G__ifunc_tableS0_St9_IdentityIS0_ESt4lessIS0_ESaIS0_EE8_M_eraseEPSt13_Rb_tree_nodeIS0_E+0x32)[0xb756ae32]
/usr/local/src/root/lib/libCint.so(_ZNSt8_Rb_treeI14G__ifunc_tableS0_St9_IdentityIS0_ESt4lessIS0_ESaIS0_EE8_M_eraseEPSt13_Rb_tree_nodeIS0_E+0x32)[0xb756ae32]
/usr/local/src/root/lib/libCint.so(_ZNSt8_Rb_treeI14G__ifunc_tableS0_St9_IdentityIS0_ESt4lessIS0_ESaIS0_EE8_M_eraseEPSt13_Rb_tree_nodeIS0_E+0x32)[0xb756ae32]
/usr/local/src/root/lib/libCint.so(_ZNSt8_Rb_treeI14G__ifunc_tableS0_St9_IdentityIS0_ESt4lessIS0_ESaIS0_EE8_M_eraseEPSt13_Rb_tree_nodeIS0_E+0x32)[0xb756ae32]
/usr/local/src/root/lib/libCint.so(_ZNSt8_Rb_treeIiSt4pairIKiSt3setI14G__ifunc_tableSt4lessIS3_ESaIS3_EEESt10_Select1stIS8_ES4_IiESaIS8_EE8_M_eraseEPSt13_Rb_tree_nodeIS8_E+0x47)[0xb756ae97]
/usr/local/src/root/lib/libCint.so[0xb755282a]
/lib/libc.so.6(__cxa_finalize+0xa8)[0xb71cf8c8]
/usr/local/src/root/lib/libCint.so[0xb748ccd3]
/usr/local/src/root/lib/libCint.so[0xb764d3ac]
/lib/ld-linux.so.2[0xb7fa9181]
/lib/libc.so.6(exit+0xd9)[0xb71cf599]
/usr/local/src/root/lib/libCore.so(_ZN11TUnixSystem4ExitEib+0x93)[0xb7a63643]
/usr/local/src/root/lib/libRint.so(_ZN5TRint9TerminateEi+0xaa)[0xb74369da]
/usr/local/src/root/lib/libCore.so[0xb7b27538]
/usr/local/src/root/lib/libCint.so(_ZN4Cint19G__ExceptionWrapperEPFiP8G__valuePKcP8G__paramiES1_PcS5_i+0x65)[0xb749d1b5]
/usr/local/src/root/lib/libCint.so(G__call_cppfunc+0x260)[0xb7585410]
/usr/local/src/root/lib/libCint.so(G__interpret_func+0xd1f)[0xb755d4cf]
/usr/local/src/root/lib/libCint.so(G__getfunction+0x1cd5)[0xb754cae5]
/usr/local/src/root/lib/libCint.so(G__getstructmem+0x4ea)[0xb761de4a]
/usr/local/src/root/lib/libCint.so(G__getvariable+0x85c)[0xb76146bc]
/usr/local/src/root/lib/libCint.so(G__getitem+0x7f)[0xb752257f]
/usr/local/src/root/lib/libCint.so(G__getexpr+0x5ab4)[0xb7529504]
/usr/local/src/root/lib/libCint.so(G__exec_statement+0xae94)[0xb75b22c4]
/usr/local/src/root/lib/libCint.so(G__exec_statement+0x6c0f)[0xb75ae03f]
/usr/local/src/root/lib/libCint.so(G__interpret_func+0x3398)[0xb755fb48]
/usr/local/src/root/lib/libCint.so(G__getfunction+0x1cd5)[0xb754cae5]
/usr/local/src/root/lib/libCint.so(G__getitem+0x6b9)[0xb7522bb9]
/usr/local/src/root/lib/libCint.so(G__getexpr+0x5ab4)[0xb7529504]
/usr/local/src/root/lib/libCint.so(G__exec_statement+0xae94)[0xb75b22c4]
/usr/local/src/root/lib/libCint.so(G__exec_statement+0x6fe6)[0xb75ae416]
/usr/local/src/root/lib/libCint.so(G__interpret_func+0x3398)[0xb755fb48]
/usr/local/src/root/lib/libCint.so(_ZN4Cint11G__CallFunc19ExecInterpretedFuncEP8G__value+0x134)[0xb74e9744]
/usr/local/src/root/lib/libCint.so(_ZN4Cint11G__CallFunc7ExecuteEPv+0x14f)[0xb74e98bf]
/usr/local/src/root/lib/libCore.so(_ZN12TQConnection13ExecuteMethodEl+0x90)[0xb79ccf10]
/usr/local/src/root/lib/libCore.so(_ZN8TQObject4EmitEPKcl+0x193)[0xb79d3103]
/usr/local/src/root/lib/libGui.so(_ZN11TGPopupMenu9ActivatedEi+0x31)[0xb60731b1]
/usr/local/src/root/lib/libGui.so(_ZN11TGMenuTitle13DoSendMessageEv+0x5b)[0xb606c5cb]
/usr/local/src/root/lib/libGui.so(_ZN9TGMenuBar12HandleButtonEP7Event_t+0x106)[0xb606e556]
/usr/local/src/root/lib/libGui.so(_ZN7TGFrame11HandleEventEP7Event_t+0x166)[0xb6021ff6]
/usr/local/src/root/lib/libGui.so(_ZN8TGClient11HandleEventEP7Event_t+0x44)[0xb5fe88f4]
/usr/local/src/root/lib/libGui.so(_ZN8TGClient15ProcessOneEventEv+0xbc)[0xb5fe8cfc]
/usr/local/src/root/lib/libGui.so(_ZN8TGClient11HandleInputEv+0x2d)[0xb5fe8d5d]
/usr/local/src/root/lib/libGui.so(_ZN14TGInputHandler6NotifyEv+0x20)[0xb5fe8d90]
/usr/local/src/root/lib/libCore.so(_ZN11TUnixSystem16DispatchOneEventEb+0x49)[0xb7a66ae9]
/usr/local/src/root/lib/libCore.so(_ZN7TSystem9InnerLoopEv+0x21)[0xb79f04f1]
/usr/local/src/root/lib/libCore.so(_ZN7TSystem3RunEv+0x71)[0xb79f41a1]
/usr/local/src/root/lib/libCore.so(_ZN12TApplication3RunEb+0x37)[0xb7993b47]
/usr/local/src/root/lib/libRint.so(_ZN5TRint3RunEb+0x398)[0xb7438078]
/usr/local/src/root/bin/root.exe(main+0x85)[0x8048ee5]
/lib/libc.so.6(__libc_start_main+0xe0)[0xb71b8fe0]
/usr/local/src/root/bin/root.exe(__gxx_personality_v0+0x65)[0x8048d91]
======= Memory map: ========
08048000-0804a000 r-xp 00000000 08:08 1293904 /usr/local/src/root/bin/root.exe
0804a000-0804b000 r–p 00001000 08:08 1293904 /usr/local/src/root/bin/root.exe
0804b000-0804c000 rw-p 00002000 08:08 1293904 /usr/local/src/root/bin/root.exe
0804c000-08704000 rw-p 0804c000 00:00 0 [heap]
b5200000-b5221000 rw-p b5200000 00:00 0
b5221000-b5300000 —p b5221000 00:00 0
b5364000-b58de000 rw-p b5364000 00:00 0
b58de000-b5964000 r-xp 00000000 08:08 1490616 /usr/local/src/root/lib/libPhysics.so
b5964000-b5966000 r–p 00085000 08:08 1490616 /usr/local/src/root/lib/libPhysics.so
b5966000-b5967000 rw-p 00087000 08:08 1490616 /usr/local/src/root/lib/libPhysics.so
b5967000-b5968000 rw-p b5967000 00:00 0
b5968000-b597d000 r-xp 00000000 08:08 1031846 /usr/lib/libICE.so.6.3.0
b597d000-b597f000 rw-p 00014000 08:08 1031846 /usr/lib/libICE.so.6.3.0
b597f000-b5981000 rw-p b597f000 00:00 0
b5981000-b5988000 r-xp 00000000 08:08 1032056 /usr/lib/libSM.so.6.0.0
b5988000-b598a000 rw-p 00006000 08:08 1032056 /usr/lib/libSM.so.6.0.0
b598a000-b59ad000 r-xp 00000000 08:08 1031962 /usr/lib/libpng12.so.0.18.0
b59ad000-b59af000 rw-p 00022000 08:08 1031962 /usr/lib/libpng12.so.0.18.0
b59af000-b5a00000 r-xp 00000000 08:08 1370929 /usr/lib/libtiff.so.3.8.2
b5a00000-b5a01000 r–p 00051000 08:08 1370929 /usr/lib/libtiff.so.3.8.2
b5a01000-b5a03000 rw-p 00052000 08:08 1370929 /usr/lib/libtiff.so.3.8.2
b5a03000-b5a21000 r-xp 00000000 08:08 1031703 /usr/lib/libjpeg.so.62.0.0
b5a21000-b5a23000 rw-p 0001d000 08:08 1031703 /usr/lib/libjpeg.so.62.0.0
b5a2c000-b5a3a000 r-xp 00000000 08:08 1426230 /usr/local/src/root/cint/include/stdfunc.dll
b5a3a000-b5a3b000 r–p 0000d000 08:08 1426230 /usr/local/src/root/cint/include/stdfunc.dll
b5a3b000-b5a3c000 rw-p 0000e000 08:08 1426230 /usr/local/src/root/cint/include/stdfunc.dll
b5a3c000-b5b2b000 r-xp 00000000 08:08 1490665 /usr/local/src/root/lib/libASImage.so
b5b2b000-b5b2f000 r–p 000ef000 08:08 1490665 /usr/local/src/root/lib/libASImage.so
b5b2f000-b5b31000 rw-p 000f3000 08:08 1490665 /usr/local/src/root/lib/libASImage.so
b5b31000-b5b3d000 rw-p b5b31000 00:00 0
b5b3d000-b5ce7000 r-xp 00000000 08:08 1490551 /usr/local/src/root/lib/libTree.so
b5ce7000-b5cee000 r–p 001aa000 08:08 1490551 /usr/local/src/root/lib/libTree.so
b5cee000-b5cf0000 rw-p 001b1000 08:08 1490551 /usr/local/src/root/lib/libTree.so
b5cf0000-b5cf2000 rw-p b5cf0000 00:00 0
b5cf2000-b5de6000 r-xp 00000000 08:08 1490547 /usr/local/src/root/lib/libNet.so
b5de6000-b5deb000 r–p 000f3000 08:08 1490547 /usr/local/src/root/lib/libNet.so
b5deb000-b5ded000 rw-p 000f8000 08:08 1490547 /usr/local/src/root/lib/libNet.so
b5ded000-b5dee000 rw-p b5ded000 00:00 0
b5dee000-b5e61000 r-xp 00000000 08:08 1490629 /usr/local/src/root/lib/libGuiBld.so
b5e61000-b5e65000 r–p 00073000 08:08 1490629 /usr/local/src/root/lib/libGuiBld.so
b5e65000-b5e66000 rw-p 00077000 08:08 1490629 /usr/local/src/root/lib/libGuiBld.so
b5e66000-b5e67000 rw-p b5e66000 00:00 0
b5e67000-b5e6b000 r-xp 00000000 08:08 1032891 /usr/lib/libXfixes.so.3.1.0
b5e6b000-b5e6d000 rw-p 00003000 08:08 1032891 /usr/lib/libXfixes.so.3.1.0
b5e6d000-b5e75000 r-xp 00000000 08:08 1371247 /usr/lib/libXcursor.so.1.0

I’ve attached it. It is pretty big (~2300 lines) but I hope some expert will be able to figure
out what I’ve done incorrectly. Just run it from Root, e.g.:

root -l TestGui.C

and then go to “Event list” → “Exit” and say “Yes” for exit. The piece of code where this exit is done is in the Bool_t TGAppMainFrame::CloseWindow() function which is at line 964.

Thanks for the help,
Balint
TestGui.C (78 KB)

Hi Balint,
Could you try to add fMain->CloseWindow() as shown there:

if (ret == kMBYes){ fMain->CloseWindow(); gApplication->Terminate(0); }
Cheers,
Bertrand.

Hi Bertrand,

I did it but the result is all the same. I use:

ROOT 5.18/00 (trunk@21744, Jun 02 2008, 11:59:00 on linux)

CINT/ROOT C/C++ Interpreter version 5.16.29, Jan 08, 2008

Cheers,
Balint

OK, I will try to reproduce the problem and let you know.
Cheers, Bertrand.

Balint,

First of all, try to compile your macro with ACLiC (.x TestGui.C+ or .L TestGui.C+) to get rid of all the errors you have in your code, and then try again, or re-post it if you want me to take a look…

Cheers,
Bertrand.

Okay, there are 2 things:

  1. I am not sure I like that I have to work with Cint but somehow for the time being that’s the
    way I have to work. And why does the code works in Cint without any error messages (except at the end) which would correspond to those that I get when I compile the code…??

  2. I don’t actually run anything when this thing occurs but only the class’s constructor is called. Within the constructor nothing happens but only the Gui classes are created and some initialization is done, so from this point of view perhaps It would be a better idea to (instead of compiling the whole ~2300 lines) just create a minimal version with which I can reproduce the problem…

Cheers,
Balint

Hi Bertrand,

okay, I created only the minimal possible version of the Gui class (attached), removed everything which doesn’t have anything to do with the Gui itself. Now I don’t get that message, so the conclusion is that then the Gui part should be (up to the constructor) OK and it was probably the additional part (that I’ve just removed) which caused that message.

I didn’t try to compile with aclic because I thought to compile my class I would have to create a dictionary via rootcint and LinkDef.h, etc - so if I will compile it I will want to make it in that way, and not the aclic way.

Anyway, thanks,
Balint
TestGui.C (30.6 KB)

Hi Balint,

  1. CINT is more flexible than compiler! To really check the validity of your code, the best way is to compile it with ACLiC. in your case, you will see plenty of C++ errors (i.e. variable redefinition, …). So first step is to check the validity of your macro…

  2. You create more than just a GUI, and even then, bad coding may lead to crashes (as you can see) :wink:

No, as said before, just use ACLiC (at least to check the validity of your code). Just type “.x TestGui.C+” or “.L TestGui.C+”. You don’t need anything else!

Cheers,
Bertrand.

Hi,

indeed I had a couple of variable redefinitions, but now it (at least the GUI part) compiles and runs as a standalone (attached, including Makefile). Sorry for not using ACLIC but somehow I am more familiar with this other way of dictionary generation and compilation.

Anyway I think the variable redefinition problems should have nothing to do with that huge message (including something like “invalid next size (fast)”) that I get at the end.

Interestingly I already saw this message elsewhere too. It was a standalone application which is also written in ROOT (it is called SFrame). What I experienced there (and here too) is that this message starts to appear after I am extending a class. After a certain amount of declaration of typically pointers to ROOT objects (e.g. TH1F *, TLorentzVector *, TCanvas * etc), if I just add one more declaration then this message shows up. And it only shows up at the end of the execution - so perhaps meaning that something went wrong at the end when the memory is being deallocating, so something must have been screwed up anyway but I just can’t find what I am doing systematically wrong so that it never shows up in smaller classes (like this GUI class attached) but only when I start to extend it…

Okay, I am not c++ expert (this attached class doesn’t have any virtual functions, and exception handling, etc…)

Cheers,
Balint
TGAppMainFrame.tar (40 KB)