Hi ROOTers, The following code produces a segmentation violation in ROOT: ---------------------------------------------------- const Int_t Max = 1025; Char_t *Text = new Char_t[Max]; for (Int_t i = 0; i < Max; i++) { Text[i] = '*'; } Text[Max-1]='\0'; Error("Crash:", "%s", Text); ---------------------------------------------------- If the number of characters is 1024 or lower then there is no segmentation violation. The debugging output is: #0 0x410ddfbf in strlen () from /lib/libc.so.6 #1 0x400ec9ba in DefaultErrorHandler (level=707406378, abort=1 '\001', location=0x2a2a2a2a <Address 0x2a2a2a2a out of bounds>, msg=0xbfffeb74 '*' <repeats 200 times>...) at base/src/TError.cxx:78 #2 0x400ecb9f in ErrorHandler (level=707406378, location=0x2a2a2a2a <Address 0x2a2a2a2a out of bounds>, fmt=0x2a2a2a2a <Address 0x2a2a2a2a out of bounds>, ap=0x2a2a2a2a) at base/src/TError.cxx:110 #3 0x2a2a2a2a in ?? () Cannot access memory at address 0x2a2a2a2a or: #0 0x410df7e5 in mempcpy () from /lib/libc.so.6 #1 0x410d5d27 in _IO_default_xsputn () from /lib/libc.so.6 #2 0x410b6c9b in vfprintf () from /lib/libc.so.6 #3 0x410cdb72 in vsprintf () from /lib/libc.so.6 #4 0x400ecafe in ErrorHandler (level=707406378, location=0x2a2a2a2a <Address 0x2a2a2a2a out of bounds>, fmt=0x2a2a2a2a <Address 0x2a2a2a2a out of bounds>, ap=0x2a2a2a2a) at base/src/TError.cxx:103 #5 0x2a2a2a2a in ?? () Cannot access memory at address 0x2a2a2a2a or something similar If one tests the code in the interpreter then the same error occures. When one replaces Error(...) with printf("%s", Text); then the interpreter output is: Limitation: printf string too long. Upto 1024. Use fputs() FILE:Error.C LINE:8 In compiled code there is no error. I think it should be similar size-limitation-problem in TError for the function Error(...). Is it possible to (a) overcome the size limitation (b) or if (a) is not possible to catch the segentation violation by testing the length of the string? Thanks Andreas OS: SuSE 7.1 ROOT: 3.01.05 ---------------------------------------------------------------------- Andreas Zoglauer MPI fuer extraterrestrische Physik Phone: +49/89-30000-3848 Postfach 1312 Fax: +49/89-30000-3569 85741 Garching, Germany Email: zog@mpe.mpg.de ----------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:49 MET