From: "Ara.T.Howard" Date: 2003-12-05T02:32:07+09:00 Subject: Re: debugging [BUG] messages/c ext woes On Thu, 4 Dec 2003, Yukihiro Matsumoto wrote: > Date: Thu, 4 Dec 2003 16:31:40 +0900 > From: Yukihiro Matsumoto > Newsgroups: comp.lang.ruby > Subject: Re: debugging [BUG] messages/c ext woes > > Hi, > > In message "debugging [BUG] messages/c ext woes" > on 03/12/04, "Ara.T.Howard" writes: > > |i'm getting a fatal error using a little c extention i've written, one of > |these (rb_fatal?) kinds: > | > | ./nfsstore.rb:123: [BUG] Segmentation fault > > Can you get the stack trace using gdb or some other debugger? > I can say little from information you've supplied. it doesn't happen too often, but here a look from strace: .... open("nfsstore", O_RDWR|O_LARGEFILE) = 3 fstat64(3, {st_mode=S_IFREG|0664, st_size=9856, ...}) = 0 fstat64(3, {st_mode=S_IFREG|0664, st_size=9856, ...}) = 0 mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x400b6000 _llseek(3, 0, [0], SEEK_CUR) = 0 read(3, "\4\10{\6:\tlist[\1\324[\10i\0\"\26jib.ngdc.noaa"..., 8192) = 8192 read(3, "1070515531.857142\0\266\324[\10i\1\261\"\26jib.n"..., 8192) = 1664 read(3, "", 8192) = 0 --- SIGSEGV (Segmentation fault) --- write(2, "./nfsstore.rb:123: ", 19./nfsstore.rb:123: ) = 19 write(2, "[BUG] ", 6[BUG] ) = 6 write(2, "Segmentation fault", 18Segmentation fault) = 18 write(2, "\nruby 1.8.0 (2003-10-15) [i686-l"..., 39 ruby 1.8.0 (2003-10-15) [i686-linux] .... line 123 is a call to Marshal::load the code i'm working on is a version of pstore modified to work on nfs mounted files. chances are quite high that two or more processes may have been able to write to the file at once (broken locking/corrupt pstore) so i'm not sure that this is a bug per se - but previous testing with corrupt pstore files has always caused load/dump errors, not core dumps. > |my understanding of StringValuePtr is that it would modifiy lockfile (lvalue) > |in place and return a char * but this is the first extenstion i've written > |since it was introduced. am i doing something silly there? should i be > |taking a copy (dup) of lockfile before doing this? everything thing else looks > |o.k. to me. > > No. It seems OK. But segmentation fault can be happen everywhere. > Might be a bug in your code, might be a bug in the core, or might be a > bug in the library you linked to the extension. history will show it is generally the first. ;-) -a -- ATTN: please update your address books with address below! =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 | STP :: http://www.ngdc.noaa.gov/stp/ | NGDC :: http://www.ngdc.noaa.gov/ | NESDIS :: http://www.nesdis.noaa.gov/ | NOAA :: http://www.noaa.gov/ | US DOC :: http://www.commerce.gov/ | | The difference between art and science is that science is what we | understand well enough to explain to a computer. | Art is everything else. | -- Donald Knuth, "Discover" | | /bin/sh -c 'for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done' ===============================================================================