From: Nobuyoshi Nakada Date: 2009-09-11T11:08:59+09:00 Subject: [ruby-core:25526] Re: [Bug #2069] Segfault in rb_enc_associate() Hi, At Thu, 10 Sep 2009 00:25:54 +0900, Jiri Zajpt wrote in [ruby-core:25501]: > ruby -v: ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin10] On darwin10, uname reports i386 but real default target is x86_64. > I am having problem with using mysql-ruby driver on Snow > Leopard. It segfaults in rb_enc_associate() used by > rb_external_str_new_with_enc() function, so I came up with > following short example (it also segfaults): It's a bug of that driver. > example source code --------------------------------------------------------------------- > > #include #include > void > Init_jzexp() > { > const char* c_str = "test"; > VALUE string = rb_external_str_new_with_enc(c_str, strlen(c_str), rb_utf8_encoding()); You should have got warning messages here. rb_utf8_encoding() returns the pointer to utf-8 rb_encoding, but undeclared functions are counted as int, and int is smaller than pointer on x86_64. Therefore only lower 32bit of the pointer is used and extended to 64bit, and results a wrong value. -- Nobu Nakada