TRandom problem

Hi,

I’m using TRandom with ROOT 4.00/04, and I’ve run into a very tricky problem. So far I’ve tried different approaches to solve it, but I’m really struggeling right now.

My program is compiled using gcc 3.1, and quite a lot input files are chained together before I loop over them. Before I loop over all the events I declare I do:

TRandom *rand1 = new TRandom(0);

In each loop rand1 is used a couple of times, but always in the following way:

float variable  = rand1->Gaus(0.,some_value);

Running the program leads to a crash with the following error statement:
*** Break *** segmentation violation
Generating stack trace…
0x41b648b8 in from /d0usr/products/rtonly/Linux-2-4/v7_1-slava/lib/libc.so.6
0x0806112b in main + 0x699 from ./runpresel
0x41b52336 in __libc_start_main at /usr/src/build/133577-i386/BUILD/glibc-2.2.4/csu/…/sysdeps/generic/libc-start.c:129 from /d0usr/products/rtonly/Linux-2-4/v7_1-slava/lib/libc.so.6
0x08057601 in TFile::TFile[in-charge](char const*, char const*, char const*, int) + 0x35 from ./runpresel
Abort

I’ve traced the error using gdb, and here is the result:
[i]

Ev: 664000 < file: to_mcmc/ztt_60_130.root
Program received signal SIGSEGV, Segmentation fault.
0x0808217c in etau_presel::Loop (this=0x8928970) at etau_presel.cc:3161
3161 float smear_metxN = rand1->Gaus(0.,Nsigma*metxf/metf);
(gdb) print smear_metxN
$1 = -0.777636588
(gdb) print Nsigma
$2 = 3
(gdb) print metxf
$3 = 17.1304188
(gdb) print metf
$4 = 17.15942
(gdb)
[/i]

I’ve printed the variable just to make clear that they’re not the cause of the problem, in fact the statement now reads:
float smear_metxN = rand1->Gaus(0.,2.99492968877);

Any ideas why it should crash??? I’ve checked the code before the crash, but I can’t find anything wrong. …

Just using one file as an input to the chain also results in a crash, however this time at a different place:
Program received signal SIGSEGV, Segmentation fault.
0x0807f85d in etau_presel::Loop (this=0x8909720) at etau_presel.cc:2701
2701 float smear_tau1=rand1->Gaus(1.,0.03);
(gdb) bt
#0 0x0807f85d in etau_presel::Loop (this=0x8909720) at etau_presel.cc:2701
#1 0x08060c9d in main (argc=1, argv=0xbfff8cb4) at etau_presel.cc:277
(gdb) where
#0 0x0807f85d in etau_presel::Loop (this=0x8909720) at etau_presel.cc:2701
#1 0x08060c9d in main (argc=1, argv=0xbfff8cb4) at etau_presel.cc:277
(gdb) print smear_tau1
$1 = 2.01089311

At this point I’ve reproduced the error. It always happen at the same event with the same value for smear_tau1.

Any help/ideas would be really appreciated.
Cheers,
Carsten

Hi Carsten,
there are two possible causes I can think of:

  1. rand1==0 or invalid (you don’t show gdb’s “print rand1” and “print *rand1”)
  2. a lib address problem. If your lib or binary expects a certain addess of Gaus in the ROOT library, and that address has changed, it might run into some place it’s not supposed to end up at. This can happen if your ROOT libs were rebuilt, but your binaries / libs linking against root libs were not. Though as far as I remember this only happens with static linking, i.e. not on linux…

Can you set a conditional breakpoint in TRandom::Gaus for the event where it crashes, poke around in Gaus itself, and send the output of that? Maybe others have better ideas, so waiting might also be an option :-]
Axel.