Creation of shared library fails on some linux's

I have attached a few files that I’ve been using to illustrate the problem. The Makefile included will compile a shared library libEventViewer.so. I can enter root and load it and use the class EventViewer it contains:

root [0] .L libEventViewer.so root [1] ev = new EventViewer() (class EventViewer*)0x10199ca00 root[2]

This works properly on a Mac running Snow Leopard with ROOT 5.27/02 and a linux box running Scientific Linux with ROOT 5.27/06. When I try to run this while logged in to a cluster running Cent OS with ROOT 5.26/00c, the shared library seems to be made fine, but the error below is returned when I try to load it. After this, all keyboard presses cause additional segmentation faults.

[code]root [0] .L libEventViewer.so
dlopen error: /share/apps/root/lib/libGui.so: undefined symbol: _ZTV6TImage
Load Error: Failed to load Dynamic link library /share/apps/root/lib/libGui.so
Error in TCint::AutoLoad: failure loading library libGui.so for class TRootGuiFactory
Error in TPluginHandler::SetupCallEnv: class TRootGuiFactory not found in plugin Gui
dlopen error: /share/apps/root/lib/libGX11TTF.so: undefined symbol: _ZN3TTF8fgGlyphsE
Load Error: Failed to load Dynamic link library /share/apps/root/lib/libGX11TTF.so
Error in TCint::AutoLoad: failure loading library libGX11TTF.so for class TGX11TTF

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

#0 0x00000030bd499c85 in waitpid () from /lib64/libc.so.6
#1 0x00000030bd43c331 in do_system () from /lib64/libc.so.6
#2 0x00002baa17598d00 in TUnixSystem::StackTrace() () from /share/apps/root/lib/libCore.so
#3 0x00002baa175969e3 in TUnixSystem::DispatchSignals(ESignals) () from /share/apps/root/lib/libCore.so
#4
#5 0x00002baa174bb1e8 in TApplication::InitializeGraphics() () from /share/apps/root/lib/libCore.so
#6 0x00002baa175167d6 in TSystem::Load(char const*, char const*, bool) () from /share/apps/root/lib/libCore.so
#7 0x00002baa174fef97 in TROOT::LoadClass(char const*, char const*, bool) () from /share/apps/root/lib/libCore.so
#8 0x00002baa17581e66 in TCint::AutoLoadCallback(char const*, char const*) () from /share/apps/root/lib/libCore.so
#9 0x00002baa17581f59 in TCint_AutoLoadCallback () from /share/apps/root/lib/libCore.so
#10 0x00002baa17ed9d9e in G__class_autoloading () from /share/apps/root/lib/libCint.so
#11 0x00002baa17edaa72 in G__defined_tagname () from /share/apps/root/lib/libCint.so
#12 0x00002baa17eec1f1 in G__defined_typename_noerror () from /share/apps/root/lib/libCint.so
#13 0x00002baa17edab54 in G__defined_tagname () from /share/apps/root/lib/libCint.so
#14 0x00002baa17edacfe in G__search_tagname () from /share/apps/root/lib/libCint.so
#15 0x00002baa17e55b9c in G__get_linked_tagnum () from /share/apps/root/lib/libCint.so
#16 0x00002baa17e565e1 in G__get_linked_tagnum_fwd () from /share/apps/root/lib/libCint.so
#17 0x00002baa19590b40 in G__cpp_setup_tagtableG__Net () from /share/apps/root/lib/libNet.so
#18 0x00002baa195ecbf7 in G__cpp_setupG__Net () from /share/apps/root/lib/libNet.so
#19 0x00002baa17e4416e in G__call_setup_funcs () from /share/apps/root/lib/libCint.so
#20 0x00002baa195f9798 in G__cpp_setup_initG__Net::G__cpp_setup_initG__Net() () from /share/apps/root/lib/libNet.so
#21 0x00002baa195904b0 in __static_initialization_and_destruction_0 () from /share/apps/root/lib/libNet.so
#22 0x00002baa195904dd in global constructors keyed to _ZN4ROOT20GenerateInitInstanceEPK8TMessage () from /share/apps/root/lib/libNet.so
#23 0x00002baa195fa8a6 in __do_global_ctors_aux () from /share/apps/root/lib/libNet.so
#24 0x00002baa19557ca3 in _init () from /share/apps/root/lib/libNet.so
#25 0x00002baa18f61a1c in ?? () from /home/mwoods/DevCode/EventViewer/./libEventViewer.so
#26 0x00000030bd00d20b in call_init () from /lib64/ld-linux-x86-64.so.2
#27 0x00000030bd00d315 in _dl_init_internal () from /lib64/ld-linux-x86-64.so.2
#28 0x00000030bd010e91 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
#29 0x00000030bd00ce96 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#30 0x00000030bd01064c in _dl_open () from /lib64/ld-linux-x86-64.so.2
#31 0x00000030bdc00f9a in dlopen_doit () from /lib64/libdl.so.2
#32 0x00000030bd00ce96 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#33 0x00000030bdc0150d in _dlerror_run () from /lib64/libdl.so.2
#34 0x00000030bdc00f11 in dlopen

GLIBC_2.2.5 () from /lib64/libdl.so.2
#35 0x00002baa17ed36cc in G__dlopen () from /share/apps/root/lib/libCint.so
#36 0x00002baa17ed4b4a in G__shl_load () from /share/apps/root/lib/libCint.so
#37 0x00002baa17e4b2ed in G__loadfile () from /share/apps/root/lib/libCint.so
#38 0x00002baa17e933b7 in G__process_cmd () from /share/apps/root/lib/libCint.so
#39 0x00002baa1758742d in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /share/apps/root/lib/libCore.so
#40 0x00002baa174bc37d in TApplication::ProcessLine(char const*, bool, int*) () from /share/apps/root/lib/libCore.so
#41 0x00002baa18b11213 in TRint::HandleTermInput() () from /share/apps/root/lib/libRint.so
#42 0x00002baa18b0fc57 in TTermInputHandler::Notify() () from /share/apps/root/lib/libRint.so
#43 0x00002baa18b1228d in TTermInputHandler::ReadNotify() () from /share/apps/root/lib/libRint.so
#44 0x00002baa175961c3 in TUnixSystem::CheckDescriptors() () from /share/apps/root/lib/libCore.so
#45 0x00002baa1759640c in TUnixSystem::DispatchOneEvent(bool) () from /share/apps/root/lib/libCore.so
#46 0x00002baa17512006 in TSystem::InnerLoop() () from /share/apps/root/lib/libCore.so
#47 0x00002baa17515271 in TSystem::Run() () from /share/apps/root/lib/libCore.so
#48 0x00002baa174baa3f in TApplication::Run(bool) () from /share/apps/root/lib/libCore.so
#49 0x00002baa18b11e80 in TRint::Run(bool) () from /share/apps/root/lib/libRint.so
#50 0x000000000040100d 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 0x00002baa174bb1e8 in TApplication::InitializeGraphics() () from /share/apps/root/lib/libCore.so
#6 0x00002baa175167d6 in TSystem::Load(char const*, char const*, bool) () from /share/apps/root/lib/libCore.so
#7 0x00002baa174fef97 in TROOT::LoadClass(char const*, char const*, bool) () from /share/apps/root/lib/libCore.so
#8 0x00002baa17581e66 in TCint::AutoLoadCallback(char const*, char const*) () from /share/apps/root/lib/libCore.so
#9 0x00002baa17581f59 in TCint_AutoLoadCallback () from /share/apps/root/lib/libCore.so

Root > .q

*** Break *** segmentation violation[/code]

Any input on why this is happening and how to fix? Also, does anyone have comments on the Makefile that I’ve made? I tried to avoid the one found in $ROOTSYS/test so that I could understand the build process more closely.
EventViewer.tar (16 KB)

How has ROOT been build on this cluster? I assume you rebuild you libEventViewer for that machine and 5.26/00c?

Cheers, Fons.

Hi Fons. Yes, the shared library is rebuilt on the cluster. ROOT is compiled from source.

I got someone to upgrade the ROOT software to 5.28/00 and the code runs fine. I guess it was a 5.26 issue?

Ah Fons! I spoke too quickly! The code does work, but something curious happens, but now on both the CentOS cluster as well as the local Linux box (but not on the Mac OS notebook).

When I load the shared library into the CINT CLI to play around, I can tab complete to investigate the methods of the EventViewer instance named ev:

$ root root [0] .L libEventViewer.so root [1] TCanvas a; root [2] ev = new EventViewer(23) (class EventViewer*)0x1c76e950 root [3] ev->Show<TAB> ShowEvent ShowMembers root [3] ev->Show

If I use the test_event_viewer.cc file that is include in the .tar, then the autocomplete function when I hit tab causes a Seg Fault!

[code]$ root test_event_viewer.cc < THIS CREATES ev INSTANCE >
root [0]
Processing test_event_viewer.cc…
root [1] ev
(class EventViewer*)0x1d93c6c0
root [2] ev->Sho
*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

#0 0x00000030bd499c85 in waitpid () from /lib64/libc.so.6
#1 0x00000030bd43c331 in do_system () from /lib64/libc.so.6
#2 0x00002b0819731299 in TUnixSystem::StackTrace() ()
from /share/apps/root/v5-28-00/lib/libCore.so
#3 0x00002b081972e4e1 in TUnixSystem::DispatchSignals(ESignals) ()
from /share/apps/root/v5-28-00/lib/libCore.so
#4
#5 0x00002b08196f2aa1 in TCint::CreateListOfDataMembers(TClass*) ()
from /share/apps/root/v5-28-00/lib/libCore.so
#6 0x00002b08196fd3ad in TClass::GetListOfDataMembers() ()
from /share/apps/root/v5-28-00/lib/libCore.so
#7 0x00002b08196fec2f in TClass::GetListOfAllPublicDataMembers() ()
from /share/apps/root/v5-28-00/lib/libCore.so
#8 0x00002b081ac2434c in TTabCom::Hook(char*, int*) ()
from /share/apps/root/v5-28-00/lib/libRint.so
#9 0x00002b0819754ce1 in rl_complete_internal(int) ()
from /share/apps/root/v5-28-00/lib/libCore.so
#10 0x00002b081975521b in _el_rl_complete(EditLine_t*, int) ()
from /share/apps/root/v5-28-00/lib/libCore.so
#11 0x00002b08197536a9 in el_gets(EditLine_t*, int*) ()
from /share/apps/root/v5-28-00/lib/libCore.so
#12 0x00002b0819755621 in readline(char const*, bool) ()
from /share/apps/root/v5-28-00/lib/libCore.so
#13 0x00002b081974f0af in Getlinem ()
from /share/apps/root/v5-28-00/lib/libCore.so
#14 0x00002b081ac1a586 in TRint::HandleTermInput() ()
from /share/apps/root/v5-28-00/lib/libRint.so
#15 0x00002b081ac191b7 in TTermInputHandler::Notify() ()
from /share/apps/root/v5-28-00/lib/libRint.so
#16 0x00002b081ac1b72d in TTermInputHandler::ReadNotify() ()
from /share/apps/root/v5-28-00/lib/libRint.so
#17 0x00002b081972e113 in TUnixSystem::CheckDescriptors() ()
from /share/apps/root/v5-28-00/lib/libCore.so
#18 0x00002b081972e64e in TUnixSystem::DispatchOneEvent(bool) ()
from /share/apps/root/v5-28-00/lib/libCore.so
#19 0x00002b08196ac5e6 in TSystem::InnerLoop() ()
from /share/apps/root/v5-28-00/lib/libCore.so
#20 0x00002b08196af9d1 in TSystem::Run() ()
from /share/apps/root/v5-28-00/lib/libCore.so
#21 0x00002b08196520af in TApplication::Run(bool) ()
from /share/apps/root/v5-28-00/lib/libCore.so
#22 0x00002b081ac1b320 in TRint::Run(bool) ()
from /share/apps/root/v5-28-00/lib/libRint.so
#23 0x000000000040100d 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 0x00002b08196f2aa1 in TCint::CreateListOfDataMembers(TClass*) ()
from /share/apps/root/v5-28-00/lib/libCore.so
#6 0x00002b08196fd3ad in TClass::GetListOfDataMembers() ()
from /share/apps/root/v5-28-00/lib/libCore.so
#7 0x00002b08196fec2f in TClass::GetListOfAllPublicDataMembers() ()
from /share/apps/root/v5-28-00/lib/libCore.so
#8 0x00002b081ac2434c in TTabCom::Hook(char*, int*) ()
from /share/apps/root/v5-28-00/lib/libRint.so
#9 0x00002b0819754ce1 in rl_complete_internal(int) ()
from /share/apps/root/v5-28-00/lib/libCore.so
#10 0x00002b081975521b in _el_rl_complete(EditLine_t*, int) ()
from /share/apps/root/v5-28-00/lib/libCore.so
#11 0x00002b08197536a9 in el_gets(EditLine_t*, int*) ()
from /share/apps/root/v5-28-00/lib/libCore.so
#12 0x00002b0819755621 in readline(char const*, bool) ()
from /share/apps/root/v5-28-00/lib/libCore.so
#13 0x00002b081974f0af in Getlinem ()
from /share/apps/root/v5-28-00/lib/libCore.so

Root > .q[/code]

Why might this be happening? Also, I’ve uploaded the files again but without the screen cluttering cout’s I had previously.
EventViewer.tar (20.5 KB)

Hi,

You must compile this class, so simply use:root test_event_viewer.cc+Cheers,
Philippe.

Philippe,

Running the test macro as you’ve said does not change the segmentation fault on the linux machines.

$ root test_event_viewer.cc+ root [0] Processing test_event_viewer.cc+... root [1] root [1] ev->Sh<TAB> *** Break *** segmentation violation ... ...

The EventViewer class is compiled into a shared library using the Makefile attached previously. Whether I create the shared library using the Makefile or by first running ACLiC (root EventViewer.cc+), when it is loaded via the test_event_viewer.cc macro tab completion for the EventViewer instance “ev” results in a seg fault, but when loaded by hand it does not. It does not happen on my laptop (Mac OS 10.6, root 5.27/02).

Thanks for the input. Any additional thoughts?

Mike

Hi,

As indicated by valgrind, there is an issue with the EventViewer code on line 118:root [0] Processing test_event_viewer.cc... ==12767== Invalid write of size 4 ==12767== at 0x8B1007B: EventViewer::ShowEvent(int) (EventViewer.cc:118) ==12767== by 0x8B0D51D: G__EventViewerDict_176_0_4(G__value*, char const*, G__param*, int) (EventViewerDict.cc:281) ==12767== Address 0xb738cc0 is 0 bytes after a block of size 6,288 alloc'd ==12767== at 0x4A05B46: operator new(unsigned long) (vg_replace_malloc.c:261) ==12767== by 0x4E74A5B: TStorage::ObjectAlloc(unsigned long) (TStorage.cxx:328) ==12767== by 0x40116C: TObject::operator new(unsigned long) (TObject.h:156) ==12767== by 0x8B0D357: G__EventViewerDict_176_0_3(G__value*, char const*, G__param*, int) (EventViewerDict.cc:263)and indeed line 118 is for (int i=0;i<122;i++) this->live[i] = MyPalette[i];to be constrasted with: Int_t live[100];.

Cheers,
Philippe

Philippe,

=D>

I appreciate you sticking to this and helping me. That fixed it. I’m very surprised that this kind of problem would show itself during tab-completion.

I am going to invest into learning to use valgrind. Hopefully I can save some of your time in the future! Thanks for illustrating its usefulness.

Mike.