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

Projects
None yet
2 participants
@jbreeden
Contributor

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 pull request Mar 5, 2016

Merge pull request #3126 from jbreeden/backtrace_irep_null_check
Null check for irep & initialize loc.lineno

@matz matz merged commit bf7719f into mruby:master Mar 5, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jbreeden jbreeden deleted the jbreeden:backtrace_irep_null_check branch Mar 5, 2016

kou added a commit to kou/mruby that referenced this pull request Mar 6, 2016

Revert "Merge pull request #3126 from jbreeden/backtrace_irep_null_ch…
…eck"

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 pull request Mar 6, 2016

Fix segmentation fault by backtrace and GC
GitHub: fix #3122

It reverts #3126. #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 referenced this pull request Mar 6, 2016

Merged

Fix SEGV by backtrace and GC #3129

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment