Actions
Bug #15021
closedSegfault when compiling certain code on Ruby 2.5.1
Description
Steps to reproduce¶
save the following code to code.rb
code =<<CODE
if false
new(arg: $arg)
end
CODE
RubyVM::InstructionSequence.compile(code).to_binary
and simply run ruby foo.rb
then you'll get
code.rb:7: [BUG] Segmentation fault at 0x0000000000000000
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin18]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
Don't forget to include the above Crash Report log file in bug reports.
-- Control frame information -----------------------------------------------
c:0003 p:---- s:0011 e:000010 CFUNC :to_binary
c:0002 p:0021 s:0007 E:000d28 EVAL code.rb:7 [FINISH]
c:0001 p:0000 s:0003 E:001c60 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
code.rb:7:in `<main>'
code.rb:7:in `to_binary'
-- Machine register context ------------------------------------------------
rax: 0x00007ffee7896b50 rbx: 0x0000000000000000 rcx: 0x0000000000000000
rdx: 0x00007ffee7896b60 rdi: 0x00007ffee7896b50 rsi: 0x00007ff0314f65f0
rbp: 0x00007ffee7896be0 rsp: 0x00007ffee7896b50 r8: 0x0000000000000001
r9: 0x0000000000000000 r10: 0x0000000000000009 r11: 0x0000000eb63a0560
r12: 0x000000000000004c r13: 0x00007ff03381c160 r14: 0x0000000000000000
r15: 0x00007ff0314f6750 rip: 0x00000001083b878e rfl: 0x0000000000010246
-- C level backtrace information -------------------------------------------
0 ruby 0x0000000108559c77 rb_vm_bugreport + 135
1 ruby 0x00000001083daa88 rb_bug_context + 472
2 ruby 0x00000001084caa61 sigsegv + 81
3 libsystem_platform.dylib 0x00007fff5f6fdd7a _sigtramp + 26
4 ruby 0x00000001083b878e ibf_dump_ci_entries + 270
5 ruby 0x000000010839f80c ibf_dump_iseq + 828
6 ruby 0x000000010839f07d iseq_ibf_dump + 397
7 ruby 0x00000001084274ca iseqw_to_binary + 74
8 ruby 0x000000010854d214 vm_call_cfunc + 292
9 ruby 0x0000000108535e01 vm_exec_core + 12785
10 ruby 0x000000010854792e vm_exec + 142
11 ruby 0x00000001083e4981 ruby_exec_internal + 177
12 ruby 0x00000001083e4878 ruby_run_node + 56
13 ruby 0x0000000108368c1f main + 79
-- Other runtime information -----------------------------------------------
* Loaded script: code.rb
* Loaded features:
0 enumerator.so
1 thread.rb
2 rational.so
3 complex.so
4 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-darwin18/enc/encdb.bundle
5 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-darwin18/enc/trans/transdb.bundle
6 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-darwin18/rbconfig.rb
7 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/compatibility.rb
8 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/defaults.rb
9 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/deprecate.rb
10 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/errors.rb
11 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/version.rb
12 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/requirement.rb
13 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/platform.rb
14 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/basic_specification.rb
15 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/stub_specification.rb
16 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/util/list.rb
17 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-darwin18/stringio.bundle
18 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/rfc2396_parser.rb
19 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/rfc3986_parser.rb
20 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/common.rb
21 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/generic.rb
22 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/ftp.rb
23 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/http.rb
24 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/https.rb
25 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/ldap.rb
26 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/ldaps.rb
27 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/mailto.rb
28 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri.rb
29 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/specification.rb
30 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/exceptions.rb
31 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_gem.rb
32 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/monitor.rb
33 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb
34 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb
35 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/dependency.rb
36 /Users/st0012/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/path_support.rb
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
[IMPORTANT]
Don't forget to include the Crash Report log file under
DiagnosticReports directory in bug reports.
[1] 77987 abort ruby code.rb
Experimented Platform and Versions¶
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin18]
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
Updated by st0012 (Stan Lo) about 6 years ago
Sorry there's a small typo. The command to run the script is ruby code.rb
not ruby foo.rb
Updated by shyouhei (Shyouhei Urabe) about 6 years ago
Can reproduce this on 2.5, but not on trunk. Seems 2.5 needs a backport?
Not sure which is the exact revision though.
Updated by rafaelfranca (Rafael França) about 6 years ago
I think this is duplicate of https://bugs.ruby-lang.org/issues/14897 which contain the fix and the backport request tags.
Updated by jeremyevans0 (Jeremy Evans) over 5 years ago
- Is duplicate of Bug #14897: Unexpected behavior of `if` in specific code added
Updated by jeremyevans0 (Jeremy Evans) over 5 years ago
- Status changed from Open to Closed
Actions
Like0
Like0Like0Like0Like0Like0