From: "Nicolas Desprès" Date: 2006-03-25T06:39:33+09:00 Subject: [BUG] ruby_script ? Hi list, That's my first post on this list, so please be patient with me. :-) The code below leads me on a SEGV in tcltklib.so $ cat test.c #include int main() { ruby_init(); ruby_script("test"); ruby_init_loadpath(); rb_eval_string("require 'tk'"); return 0; } $ gcc -o test test.c -L/opt/ruby-1.8.4/lib -lruby -I/opt/ruby-1.8.4/lib/ruby/1.8/i686-linux $ ./test /opt/ruby-1.8.4/lib/ruby/site_ruby/1.8/i686-linux/tcltklib.so: [BUG] Segmentation fault ruby 1.8.4 (2005-12-24) [i686-linux] zsh: abort ./test $ After debugging it, I figure out that the bug comes from the fact rb_argv0 was not initialized (the SEGV happens on line 7932 of the file tcltklib.c). Then, I fixed my progam this way: > $ cat test.c > #include > EXTERN VALUE rb_progname; EXTERN VALUE rb_argv0; > int main() > { > ruby_init(); > ruby_script("test"); rb_argv0 = rb_progname; > ruby_init_loadpath(); > rb_eval_string("require 'tk'"); > return 0; > } I noticed that using ruby_options also solves the problem since ruby_process_options does a "rb_argv0 = rb_progname" right after ruby_script, as I do in my code. Using ruby_options leads my program to sleep since ruby_options reads stdin which I don't want. Thus, I'm wondering whether ruby_script should always initialized rb_argv0 to avoid such issue. Best regards, -- Nicolas Despr�s