c extenders-
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
i’m unsure if this is truly a ‘BUG’ or bad code on my part - here’s the call
in c:
VALUE
rb_lockfile_s_create(klass, lockfile, retrycnt, flags)
VALUE klass;
VALUE lockfile;
VALUE retrycnt;
VALUE flags;
{
return
INT2NUM(lockfile_create(StringValuePtr(lockfile),NUM2INT(retrycnt),NUM2INT(flags)));
}
lockfile_create has this signature:
int lockfile_create( const char *lockfile, int retrycnt, int flags );
i’m calling this from ruby as in
lockfile_create (“foobar.lock”, 16, 0)
thing is, this does work. sometimes.
othertimes it 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.
thanks for for any insight.
if there’s nothing wrong with the above i’ll start looking into
lockfile_create, which is from liblockfile and could be buggy.
-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 :: Solar-Terrestrial Physics Data | NCEI
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’
===============================================================================