From: Nobuyoshi Nakada Date: 2008-02-19T09:48:25+09:00 Subject: Re: Different stacktraces in 1.8 and 1.9 Hi, At Tue, 19 Feb 2008 04:30:32 +0900, Vladimir Sizikov wrote in [ruby-core:15589]: > 1. 1/0 > > It was producing nice stack trace in MRI 1.8.6: > ZeroDivisionError: divided by 0 > from (irb):1:in `/' > from (irb):1 > > In MRI 1.9 the stack trace don't even mention the method name! > ZeroDivisionError: divided by 0 > from (irb):1 > from /opt/ruby1.9/lib/ruby/1.9.0/irb.rb:149:in `block (2 > levels) in eval_input' > from /opt/ruby1.9/lib/ruby/1.9.0/irb.rb:262:in `signal_status' > from /opt/ruby1.9/lib/ruby/1.9.0/irb.rb:146:in `block in eval_input' This would be an irb issue. > If invoked not from irb, but from a script file, the method name still > is not reported: > div.rb:1:in `
': divided by 0 (ZeroDivisionError). > > MRI 1.8.6 produces better output in such case: > div.rb:1:in `/': divided by 0 (ZeroDivisionError) > from div.rb:1 Agreed it is better. > 2. raise RuntimeError, "heh" > > In MRI 1.8: > RuntimeError: heh > from (irb):2 > > In MRI 1.9, one extra line is reported: > RuntimeError: heh > from (irb):3:in `raise' > from (irb):3 > > Is it really needed to have the extra line with `raise'? No. Index: eval.c =================================================================== --- eval.c (revision 15543) +++ eval.c (working copy) @@ -226,7 +226,7 @@ ruby_exec_node(void *n, char *file) PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { + VALUE iseq = rb_iseq_new(n, rb_str_new2("
"), + rb_str_new2(file), Qfalse, ISEQ_TYPE_TOP); SAVE_ROOT_JMPBUF(th, { - VALUE iseq = rb_iseq_new(n, rb_str_new2("
"), - rb_str_new2(file), Qfalse, ISEQ_TYPE_TOP); th->base_block = 0; val = rb_iseq_eval(iseq); @@ -776,5 +776,7 @@ rb_f_raise(int argc, VALUE *argv) } } - rb_raise_jump(rb_make_exception(argc, argv)); + err = rb_make_exception(argc, argv); + GET_THREAD()->cfp++; + rb_raise_jump(err); return Qnil; /* not reached */ } Index: insns.def =================================================================== --- insns.def (revision 15543) +++ insns.def (working copy) @@ -1514,5 +1514,5 @@ opt_div long mod; if (y == 0) - rb_num_zerodiv(); + goto INSN_LABEL(normal_dispatch); if (y < 0) { if (x < 0) -- Nobu Nakada