Bug with declaring non-pointer TRandom?

Hi,

Compiling the following four line program with g++ 4.4 leads to a segmentation fault:

[code]#include <TRandom3.h>
#include <stdio.h>
#include <time.h>

int main() {

TRandom3 rnd;
rnd.SetSeed(time(NULL));
printf("%d\n",rnd.Rndm());
    return 0;

}[/code]

When changing the TRandom3 variable to a pointer:

The program runs just fine.

Is this a bug in cint? I’m running ROOT 5.18 if that’s any help.

Hi,

Are you compiling or interpreting this example? Can you try v5.30?

Cheers,
Philippe.

Correction: This happens in root 5.28 not 5.18.
As said, compiling with g++ 4.4, by linking with “root-config --libs”. No problem with Interpreted.
I will download 2.30 and see if this changes anything.

Indeed, the bug looks like a bug in cint (5.18):

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff72311ae in G__herits::operator[] (this=0x674618, idx=0) at cint/cint/src/common.h:1178 1178 if (herits->id == idx) {

with a backtrace:

#0 0x00007ffff72311ae in G__herits::operator[] (this=0x674618, idx=0) at cint/cint/src/common.h:1178 #1 0x00007ffff72ea662 in G__isanybase (basetagnum=24, derivedtagnum=8, pobject=2) at cint/cint/src/inherit.cxx:872 #2 0x00007ffff73a89f1 in G__defined_tagname ( tagname=0x7ffff328f0e0 "vector<string,allocator<string> >::iterator", noerror=3) at cint/cint/src/struct.cxx:1670 #3 0x00007ffff73a8fde in G__search_tagname ( tagname=0x7ffff328f0e0 "vector<string,allocator<string> >::iterator", type=99) at cint/cint/src/struct.cxx:1805 #4 0x00007ffff7307d3d in G__get_linked_tagnum (p=0x7ffff35e87d0) at cint/cint/src/newlink.cxx:3490 #5 0x00007ffff7307d99 in G__get_linked_tagnum_fwd (p=0x7ffff35e87d0) at cint/cint/src/newlink.cxx:3505 #6 0x00007ffff308cdc8 in G__cpp_setup_tagtableG__Base2 () at core/base/src/G__Base2.cxx:31096 #7 0x00007ffff308ce54 in G__cpp_setupG__Base2 () at core/base/src/G__Base2.cxx:31102 #8 0x00007ffff72eaefc in G__call_setup_funcs () at cint/cint/src/init.cxx:160 #9 0x00007ffff2e70613 in TCint::InitializeDictionaries (this=0x640df0) at $ROOT/core/meta/src/TCint.cxx:375 #10 0x00007ffff2e8a76e in TClass::Init(char const*, short, std::type_info const*, TVirtualIsAProxy*, void (*)(void*, TMemberInspector&), char const*, char const---Type <return> to continue, or q <return> to quit--- *, int, int, bool) () from $ROOT/lib/libCore.so #11 0x00007ffff2e8aca2 in TClass::TClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, void (*)(void*, TMemberInspector&), char const*, char const*, int, int, bool) () from $ROOT/lib/libCore.so #12 0x00007ffff2e8ae58 in ROOT::CreateClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, void (*)(void*, TMemberInspector&), char const*, char const*, int, int) () from $ROOT/lib/libCore.so #13 0x00007ffff6af8b46 in ROOT::TDefaultInitBehavior::CreateClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, void (*)(void*, TMemberInspector&), char const*, char const*, int, int) const () from $ROOT/lib/libNet.so #14 0x00007ffff2e98895 in ROOT::TGenericClassInfo::GetClass() () from $ROOT/lib/libCore.so #15 0x00007ffff2fc601b in TObjString::Class () at core/base/src/G__Base2.cxx:2693 #16 0x00007ffff2df7038 in TObjString::IsEqual(TObject const*) const () from $ROOT/lib/libCore.so #17 0x00007ffff2e6130d in TList::FindObject(TObject const*) const () from $ROOT/lib/libCore.so #18 0x00007ffff2e63b45 in TMap::Remove(TObject*) () from $ROOT/lib/libCore.so #19 0x00007ffff2e595a1 in TClassTable::Remove(char const*) () from $ROOT/lib/libCore.so ---Type <return> to continue, or q <return> to quit--- #20 0x00007ffff6af8ae6 in ROOT::TDefaultInitBehavior::Unregister(char const*) const () from /media/Work/School/Thesis/root/lib/libNet.so #21 0x00007ffff2e9957e in ROOT::TGenericClassInfo::~TGenericClassInfo() () from $ROOT/lib/libCore.so #22 0x00007ffff1effd3d in __cxa_finalize (d=0x7ffff7192fc0) at cxa_finalize.c:56 #23 0x00007ffff6da5546 in __do_global_dtors_aux () from $ROOT/lib/libRIO.so #24 0x0000000000000000 in ?? ()

Hi,

This is a bit odd, I suspect there is a problem with LD_LIBRARY_PATH, ROOTSYS, root-config not all pointing to the same version of ROOT.

Cheers,
Philippe.