Strange Behavior

The problem seems to be in c code calling ruby calling c code.

======== start test.rb
puts "about to require curses"
require "curses"
puts “curses loaded”
======== end test.rb
======== start simple.c
#include “ruby.h”

int main()
{
ruby_init();
ruby_init_loadpath();
rb_require(“test.rb”);
return 0;
}
======== end simple.c

$ ruby test.rb
about to require curses
curses loaded

$ gcc -o simple -I/usr/lib/ruby/1.6/i386-linux/ simple.c
-L/usr/lib/ruby/1.6/i386-linux/ -lruby -ldl -lcrypt -lm

$ ./simple
about to require curses
…/test.rb:2: [BUG] Segmentation fault
ruby 1.6.7 (2002-03-19) [i386-linux]
Aborted

There is nothing special about the curses extension, this happens for any
extensions. I don’t know what to do about this, and I’d appreciate any
help beyond the level of “re-install a new version of ruby” since I don’t
have control over this distribution.

I’ve made this work on a Darwin6.6 machine, so I suspect there is some
disagreement between these guys:
$ gcc --version
2.96
$ ruby --version
ruby 1.6.7 (2002-03-19) [i386-linux]

Any ideas would be appreciated.
Thanks,
Todd

Hi,

···

In message “Strange Behavior” on 03/10/03, Todd Phillips tp517@andrew.cmu.edu writes:

The problem seems to be in c code calling ruby calling c code.

$ gcc -o simple -I/usr/lib/ruby/1.6/i386-linux/ simple.c
-L/usr/lib/ruby/1.6/i386-linux/ -lruby -ldl -lcrypt -lm

On Linux, you need to specify -rdynamic, if you want to load extension
from your program.

						matz.