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

Null check for irep & initialize loc.lineno #3126

Merged
merged 2 commits into from Mar 5, 2016

Conversation

jbreeden
Copy link
Contributor

@jbreeden jbreeden commented Mar 5, 2016

Was really hoping to solve #3118 (& therefor jbreeden/mruby-apr#9), but no such luck.

Still, this fixes the segfault in #3122 for me.

[jared:~/projects/mruby-spec] cat test.rb 
def gen
  e0 = nil
  begin
    1.times {
      raise 'foobar'
    }
  rescue => e
    e0 = e
  end
  e0
end

e = gen
GC.start
gen
GC.start

p e.backtrace
[jared:~/projects/mruby-spec] mruby ./test.rb 
["./test.rb:18"]

(Of course, the backtrace is still losing information about where the exception was actually raised)

matz added a commit that referenced this issue Mar 5, 2016
Null check for irep & initialize loc.lineno
@matz matz merged commit bf7719f into mruby:master Mar 5, 2016
1 check passed
@jbreeden jbreeden deleted the backtrace_irep_null_check branch Mar 5, 2016
kou added a commit to kou/mruby that referenced this issue Mar 6, 2016
…ll_check"

This reverts commit bf7719f, reversing
changes made to 4f4fa0a.

We should get backtrace while irep is alive.
kou added a commit to kou/mruby that referenced this issue Mar 6, 2016
GitHub: fix mruby#3122

It reverts mruby#3126. mruby#3126 fixes the segmentation fault but generates
broken backtrace.

This change fixes the segmentation fault and generates correct
backtrace. The strategy of this change is "generating backtrace while
irep is alive".

/tmp/test.rb:
    def gen
      e0 = nil
      begin
        1.times {
          raise 'foobar'
        }
      rescue => e
        e0 = e
      end
      e0
    end

    e = gen
    GC.start
    gen
    GC.start

    puts e.backtrace.join("\n")

Run:

    % bin/mruby /tmp/test.rb
    /tmp/test.rb:5:in Object.gen
    /home/kou/work/ruby/mruby.kou/mrblib/numeric.rb:77:in Integral#times
    /tmp/test.rb:4:in Object.gen
    /tmp/test.rb:13

FYI:

    % ruby -v /tmp/test.rb
    ruby 2.3.0p0 (2015-12-25) [x86_64-linux-gnu]
    /tmp/test.rb:5:in `block in gen'
    /tmp/test.rb:4:in `times'
    /tmp/test.rb:4:in `gen'
    /tmp/test.rb:13:in `<main>'
@kou kou mentioned this pull request Mar 6, 2016
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

Successfully merging this pull request may close these issues.

None yet

2 participants