From: Edwin Pratomo Date: 2008-01-12T22:44:24+09:00 Subject: rb_rescue2 crashes 1.9.0-0 good day all, the following rb_rescue2 works with old versions - tested with 1.8.5 and 1.8.6. but crashes 1.9.0-0. something's wrong with the code or is it a problem in 1.9.0-0's rb_rescue2? #include #include #ifndef RSTRING_PTR #define RSTRING_PTR(o) RSTRING(o)->ptr #endif static VALUE eval_failed(VALUE v, VALUE exc) { printf("eval_failed\n"); return exc; } int main() { VALUE retv; int i; char *codes[] = { "de foo; puts \"in foo()\"; end", "1/0" }; ruby_init(); ruby_init_loadpath(); for (i = 0; i < 2; i++) { #ifdef USE_RB_STR_NEW2 retv = rb_rescue2(rb_eval_string, rb_str_new2(codes[i]), eval_failed, Qnil, rb_eException, 0); #else retv = rb_rescue2(rb_eval_string, (VALUE)codes[i], eval_failed, Qnil, rb_eException, 0); #endif if (rb_obj_is_kind_of(retv, rb_eException)) { VALUE msg = rb_funcall(retv, rb_intern("message"), 0); printf("Error: %s\n", RSTRING_PTR(msg)); } } ruby_finalize(); exit(0); } rgds, Edwin ________________________________________________________ Bergabunglah dengan orang-orang yang berwawasan, di di bidang Anda! Kunjungi Yahoo! Answers saat ini juga di http://id.answers.yahoo.com/