From: Ariff Abdullah Date: 2002-12-29T14:12:17+09:00 Subject: Re: string.c (str_alloc) ruby 1.8 + ruby-gtk crash Here is the poc: poc.c :- #include "ruby.h" #include VALUE poC; static VALUE poc_run(self, str) VALUE self, str; { const char *dummy = STR2CSTR(str); if (dummy) { printf("OK : \"%s\"\n", dummy); } else { printf("Where am I ?!?!?!?\n"); } return self; } void Init_poc() { poC = rb_define_class("Poc", rb_cObject); rb_define_singleton_method(poC, "run", poc_run, 1); } extconf.rb :- require 'mkmf' create_makefile("poc") and the poc_test.rb :- require 'poc' a = ARGV[0] || '' b = a.dup() Poc.run(b) and now.. [sky@wizard poc]# ./poc_test.rb OK : "" [sky@wizard poc]# ./poc_test.rb " " OK : " " [sky@wizard poc]# ./poc_test.rb "a" OK : "a" [sky@wizard poc]# ./poc_test.rb "" ./poc_test.rb:41: [BUG] Segmentation fault ruby 1.8.0 (2002-12-28) [i386-freebsd4] Abort trap (core dumped) [root@wizard poc]# str.len = 0 (string.c , str_alloc()) , str.ptr = 0 ? nobu.nokada@softhome.net wrote: > Hi, > > At Sun, 29 Dec 2002 05:21:43 +0900, > Ariff Abdullah wrote: > >>[sky@wizard build]# ./ruby /tmp/bla.rb '' >>Gdk-CRITICAL **: file gdkfont.c: line 319 (gdk_string_width): >>assertion `string != NULL' failed. > > > Update ruby-gtk. In 1.8, extension libraries have to consider > the case RSTRING(string)->ptr is NULL. >