From: Nobuyoshi Nakada Date: 2009-04-21T15:05:22+09:00 Subject: Re: questions about embedding ruby 1.9 Hi, At Tue, 21 Apr 2009 08:43:00 +0900, Rolando Abarca wrote in [ruby-talk:334502]: > Everything works just fine if there's no exception raised in the code. > If an exception is raised, I get a BAD_ACCESS error, on vm.c, line 743: > > ary = vm_backtrace_each(th, RUBY_VM_NEXT_CONTROL_FRAME(cfp), > top_of_cfp, RSTRING_PTR(th->vm->progname), 0, ary); > > The backtrace (in the test case) is because of a method missing not > being handled... What's the way to go with ruby1.9 and exception > handling when embedding the interpreter? > I've searched the net, but so far I've only found articles about > embedding ruby 1.8 and not 1.9... I can't see any problem with following code. #include "ruby.h" int main(int argc, char **argv) { int state; ruby_sysinit(&argc, &argv); { RUBY_INIT_STACK; ruby_init(); rb_protect(RUBY_METHOD_FUNC(rb_require), (VALUE)"./main.rb", &state); } return ruby_cleanup(state); } -- Nobu Nakada