Dear ROOTers, I use a linux computer with the following compiler gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-81). I have encountered segfaults crashes in the program enclosed in the attachment when I used the ROOT binaries present on the system (dec 2002 version). THe program crashed in method TTree::Fill, TTree::Print and TObject::Write(). So I decided to upgrade to ROOT 3.05.02.I have done so,the programs compiles fine, but it now segfaults almost immediately at a different location. The stack trace is : *** Break *** segmentation violation Generating stack trace... 0x4021338f in TUnixSystem::StackTrace(void) + 0x25b from /home/daplxa119/mnt/mfechner/root/lib/libCore.so 0x40211f82 in TUnixSystem::DispatchSignals(ESignals) + 0xb2 from /home/daplxa119/mnt/mfechner/root/lib/libCore.so 0x4021112b in TWebFile::GetSize(void) const + 0x9b from /home/daplxa119/mnt/mfechner/root/lib/libCore.so 0x40214c61 in TUnixSystem::GetSockOpt(int, int, int *) + 0x339 from /home/daplxa119/mnt/mfechner/root/lib/libCore.so 0x415b9935 in sigaction at /usr/src/bs/BUILD/glibc-2.2.2/linuxthreads/signals.c:97 from /lib/i686/libpthread.so.0 0x413bd648 in killpg at /usr/src/bs/BUILD/glibc-2.2.2/signal/../sysdeps/posix/killpg.c:34 from /lib/i686/libc.so.6 0x08048feb in main + 0xdb from ./Range.exe 0x413ac177 in __libc_start_main at /usr/src/bs/BUILD/glibc-2.2.2/csu/../sysdeps/generic/libc-start.c:129 from /lib/i686/libc.so.6 0x08048ad1 in _start + 0x21 from ./Range.exe Abandon (core dumped) Analysis of the core dump gives the following output with gbd's 'backtrace' command : (gdb) bt #0 0x413bd801 in __kill () from /lib/i686/libc.so.6 #1 0x413bd5da in raise (sig=6) at ../sysdeps/posix/raise.c:27 #2 0x413bed82 in abort () at ../sysdeps/generic/abort.c:88 #3 0x40213134 in TUnixSystem::StackTrace () from /home/daplxa119/mnt/mfechner/root/lib/libCore.so #4 0x40212028 in TUnixSystem::DispatchSignals () from /home/daplxa119/mnt/mfechner/root/lib/libCore.so #5 0x4021112b in SigHandler () from /home/daplxa119/mnt/mfechner/root/lib/libCore.so #6 0x40214c61 in sighandler () from /home/daplxa119/mnt/mfechner/root/lib/libCore.so #7 0x415b9935 in pthread_sighandler (signo=11, ctx= {gs = 7, __gsh = 0, fs = 0, __fsh = 0, es = 43, __esh = 0, ds = 43, __dsh = 0, edi = 3221222460, esi = 1073834852, ebp = 3221222248, esp = 3221222080, ebx = 134522336, edx = 1635282324, ecx = 4, eax = 134517747, trapno = 14, err = 4, eip = 134516109, cs = 35, __csh = 0, eflags = 66050, esp_at_signal = 3221222080, ss = 43, __ssh = 0, fpstate = 0xbffff040, oldmask = 2147483648, cr2 = 1635282324}) at signals.c:97 #8 <signal handler called> #9 0x08048d8d in DataFill (Arb=0x8698a40, typ=0x804938d "e") at Range.cpp:53 #10 0x08048feb in main () at Range.cpp:77 #11 0x413ac177 in __libc_start_main (main=0x8048f10 <main>, argc=1, ubp_av=0xbffff43c, init=0x8048930 <_init>, fini=0x8049290 <_fini>, rtld_fini=0x4000e184 <_dl_fini>, stack_end=0xbffff42c) at ../sysdeps/generic/libc-start.c:129 My source code is ( see attachments) : struct EnergyLossData { double energy; double dedx; double range; }; void DataFill(TTree* Arb, const char* typ) { static char* MCPATH = "MCPATH"; char* datapath = getenv(MCPATH); char* filename;char line[45]; EnergyLossData ElData; double a1,a2; FILE* dat; if (datapath == NULL) { fprintf(stderr,"Environment variable %s is not defined.\n",MCPATH); fprintf(stderr,"Make %s point to the directory which holds all data tables for de/dx, etc..\n",MCPATH); exit(2); } if ( strcmp(typ,"e") == 0 ) { sprintf(filename,"%s/electron_loss.dat",datapath);a2= ELEC_MASS;printf("%s\n",filename);fflush(stdout);} else if ( strcmp(typ,"m") == 0) { sprintf(filename,"%s/muon_loss.dat",datapath);a2 = MUON_MASS;printf("%s\n",filename); fflush(stdout);} else { fprintf(stderr,"Option %s not recognized\n",typ); fprintf(stderr,"Exiting to system\n"); exit(2); } dat = fopen(filename,"r"); Arb->Branch("Energy",&ElData.energy,"Energy/D"); Arb->Branch("Dedx",&ElData.dedx,"Dedx/D"); Arb->Branch("Range",&ElData.range,"Range/D"); if (dat != NULL) { while ( fgets(line,45,dat)) { sscanf(&line[0],"%lG",&a1); ElData.energy = a1 + a2; sscanf(&line[9],"%lG",&ElData.dedx); sscanf(&line[19],"%lG",&ElData.range); printf("%lG %lG %lG\n",ElData.energy,ElData.dedx,ElData.range); fflush(stdout); Arb->Fill(); } Arb->Print(); //Arb->Write(); fclose(dat); } } int main() { TFile* f1 = new TFile("elec.root","recreate"); TTree* t1 = new TTree("elec_loss","Energy loss table for electrons"); DataFill(t1,"e"); t1->Write(); f1->Write(); f1->Close(); TFile* f2 = new TFile("muon.root","recreate"); TTree* t2 = new TTree("muon_loss","Energy loss table for muons"); DataFill(t2,"m"); t2->Write(); f2->Write(); f2->Close(); return 0; } I am quite puzzled (problem with pthread ?). Do you have any idea what I am doing wrong ? Thanking you in advance, Yours Maximilien Fechner
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET