Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing last element in backtrace #3660

Closed
asfluido opened this issue May 17, 2017 · 0 comments
Closed

Missing last element in backtrace #3660

asfluido opened this issue May 17, 2017 · 0 comments

Comments

@asfluido
Copy link

Hello world. If I execute this little test script:

class C
  def runme    
    raise 'a'
  end
end

C::new.runme

I obtain the expected output:

trace:
	[0] /tmp/test1.rb:3:in C.runme
	[1] /tmp/test1.rb:7
/tmp/test1.rb:3:a (RuntimeError)

If my script is, instead, this one:

class C
  def runme    
    a=1*nonexisting
  end
end

C::new.runme

(that is, if I try to make use of a non-existing variable), this is the result:

trace:
	[0] /tmp/test2.rb:7
/tmp/test2.rb:7:undefined method 'nonexisting' for #<C:0x2376170> (NoMethodError)

As you can see, the most recent line of the backtrace is missing. I got it back by commenting the following three lines from backtrace.c (currently at L.275):

  else if (mrb->backtrace.n > 0) {
    print_backtrace_saved(mrb);
  }

I now receive:

trace:
	[1] /tmp/test2.rb:3:in C.runme
	[0] /tmp/test2.rb:7
/tmp/test2.rb:7:undefined method 'nonexisting' for #<C:0x1438170> (NoMethodError)

but this is most probably not the proper fix: I have recovered the missing backtrace element, but the error message still points to the wrong script line (7 instead of 3).

Ideas?

@matz matz closed this as completed in 9bca887 May 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant