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 <ruby.h>
#include <stdio.h>

#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/

“E” == Edwin P. [email protected] writes:

E> the following rb_rescue2 works with old versions - tested with 1.8.5
and
E> 1.8.6. but crashes 1.9.0-0. something’s wrong with the code or is it
a
E> problem in 1.9.0-0’s rb_rescue2?

See [ruby-talk:286536]

http://blade.nagaokaut.ac.jp/ruby/ruby-talk/286536

You must at least call RUBY_INIT_STACK and use rb_protect()

Guy Decoux

“E” == Edwin P. [email protected] writes:

E> is it a problem in 1.9.0-0’s rb_rescue2?

Well, apparently there is also a problem in 1.9.0 but it’s not specific
to
rb_rescue2(). I’ll send a message to ruby-core to try to explain
it.

Guy Decoux

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs