Project

General

Profile

Actions

Bug #15200

closed

RubyVM::InstructionSequence can not compile to binary from method call with hash in 'if false' expression

Added by okwrtdsh (Tadashi Okawara) about 6 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
[ruby-core:89272]

Description

These works as expected:

  • if true
$ ruby -e 'RubyVM::InstructionSequence.compile("if true\nfoo bar: 1\nend").to_binary'
  • method call without hash arguments
$ ruby -e 'RubyVM::InstructionSequence.compile("if false\nfoo bar\nend").to_binary'
  • use a variable
$ ruby -e 'RubyVM::InstructionSequence.compile("baz = false\nif baz\nfoo bar: 1\nend").to_binary'
  • compile to array
$ ruby -e 'RubyVM::InstructionSequence.compile("if false\nfoo bar: 1\nend").to_a'

This throws an error:

$ ruby -e 'RubyVM::InstructionSequence.compile("if false\nfoo bar: 1\nend").to_binary'
-e:1: [BUG] Segmentation fault at 0x0000000000000000
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]

-- 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:0010 e:000009 CFUNC  :to_binary
c:0002 p:0017 s:0006 e:000005 EVAL   -e:1 [FINISH]
c:0001 p:0000 s:0003 E:000ea0 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
-e:1:in `<main>'
-e:1:in `to_binary'

-- Machine register context ------------------------------------------------
 rax: 0x0000000000000000 rbx: 0x0000000000000018 rcx: 0x00007ffee001c680
 rdx: 0x0000000000000008 rdi: 0x00007ffee001c670 rsi: 0x00007fd66d8489b0
 rbp: 0x00007ffee001c710 rsp: 0x00007ffee001c670  r8: 0x0003f145338f8b9f
  r9: 0x0000000000000001 r10: 0x0082234024000800 r11: 0x00000028727d3cc0
 r12: 0x000000000000004c r13: 0x00007ffee001c670 r14: 0x0000000000000000
 r15: 0x00007fd66d848390 rip: 0x000000010fc3246a rfl: 0x0000000000010246

-- C level backtrace information -------------------------------------------
0   libruby.2.5.dylib                   0x000000010fdbeea7 rb_vm_bugreport + 135
1   libruby.2.5.dylib                   0x000000010fc52c17 rb_bug_context + 327
2   libruby.2.5.dylib                   0x000000010fd34858 sigsegv + 72
3   libsystem_platform.dylib            0x00007fff7a390f5a _sigtramp + 26
4   libruby.2.5.dylib                   0x000000010fc3246a ibf_dump_ci_entries + 266
5   libruby.2.5.dylib                   0x000000010fc1aac6 ibf_dump_iseq + 854
6   libruby.2.5.dylib                   0x000000010fc1a30f iseq_ibf_dump + 415
7   libruby.2.5.dylib                   0x000000010fc98dca iseqw_to_binary + 74
8   libruby.2.5.dylib                   0x000000010fdb2af1 vm_call_cfunc + 289
9   libruby.2.5.dylib                   0x000000010fd9e1f2 vm_exec_core + 11522
10  libruby.2.5.dylib                   0x000000010fdad000 vm_exec + 144
11  libruby.2.5.dylib                   0x000000010fc59131 ruby_exec_internal + 177
12  libruby.2.5.dylib                   0x000000010fc59028 ruby_run_node + 56
13  ruby                                0x000000010fbe2f2f main + 79

-- Other runtime information -----------------------------------------------

* Loaded script: -e

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-darwin17/enc/encdb.bundle
    5 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-darwin17/enc/trans/transdb.bundle
    6 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-darwin17/rbconfig.rb
    7 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/compatibility.rb
    8 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/defaults.rb
    9 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/deprecate.rb
   10 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/errors.rb
   11 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/version.rb
   12 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/requirement.rb
   13 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/platform.rb
   14 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/basic_specification.rb
   15 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/stub_specification.rb
   16 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/util/list.rb
   17 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-darwin17/stringio.bundle
   18 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/rfc2396_parser.rb
   19 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/rfc3986_parser.rb
   20 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/common.rb
   21 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/generic.rb
   22 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/ftp.rb
   23 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/http.rb
   24 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/https.rb
   25 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/ldap.rb
   26 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/ldaps.rb
   27 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri/mailto.rb
   28 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/uri.rb
   29 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/specification.rb
   30 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/exceptions.rb
   31 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/dependency.rb
   32 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_gem.rb
   33 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/monitor.rb
   34 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb
   35 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb
   36 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/path_support.rb
   37 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib/did_you_mean/version.rb
   38 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib/did_you_mean/core_ext/name_error.rb
   39 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib/did_you_mean/levenshtein.rb
   40 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib/did_you_mean/jaro_winkler.rb
   41 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib/did_you_mean/spell_checker.rb
   42 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/2.5.0/delegate.rb
   43 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
   44 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
   45 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib/did_you_mean/spell_checkers/name_error_checkers.rb
   46 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib/did_you_mean/spell_checkers/method_name_checker.rb
   47 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib/did_you_mean/spell_checkers/key_error_checker.rb
   48 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib/did_you_mean/spell_checkers/null_checker.rb
   49 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib/did_you_mean/formatters/plain_formatter.rb
   50 /Users/tadashi-okawara/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib/did_you_mean.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.

The same error occurs in following versions:

  • ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
  • ruby 2.5.2p91 (2018-10-01 revision 64893) [x86_64-darwin17]
  • ruby 2.6.0preview1 (2018-02-24 trunk 62554) [x86_64-darwin17]

The same error does not occur in following versions:

  • ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-darwin17]
  • ruby 2.6.0dev (2018-10-03 trunk 64910) [x86_64-darwin17]

Files

ruby_2018-10-04-012836_P1097-17P15U.crash (36.7 KB) ruby_2018-10-04-012836_P1097-17P15U.crash Crash Report log file okwrtdsh (Tadashi Okawara), 10/03/2018 04:32 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #15392: Crash in RubyVM::InstructionSequence#to_binaryClosedActions
Actions #1

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Is duplicate of Bug #14897: Unexpected behavior of `if` in specific code added
Actions #2

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Is duplicate of deleted (Bug #14897: Unexpected behavior of `if` in specific code)

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

Seems fixed by a series of commits: 61846 61913 62615 62621 62622 62772 62777 62778 62787 62791 62796 62807 62856 63098 63099 63101 63102 63103 63113 63116 63117 63118 63119 63167 63368

Updated by wanabe (_ wanabe) about 6 years ago

okwrtdsh (Tadashi Okawara) wrote:

This throws an error:

$ ruby -e 'RubyVM::InstructionSequence.compile("if false\nfoo bar: 1\nend").to_binary'

It seems the same as https://bugs.ruby-lang.org/issues/14553#note-3 = ruby-core:86400.

$ ./miniruby -v -e 'RubyVM::InstructionSequence.compile("if false\nfoo bar: 1\nend").to_binary; p :done'
ruby 2.6.0dev (2018-03-30 trunk 63040) [x86_64-linux]
:done

$ git checkout HEAD~
Previous HEAD position was 484cc6b3bc compile.c: do not dump unused callinfos
HEAD is now at c493503625 * 2018-03-30

$ (make REVISION_FORCE=PHONY incs; make miniruby -j4) > /dev/null

$ ./miniruby -v -e 'RubyVM::InstructionSequence.compile("if false\nfoo bar: 1\nend").to_binary; p :done'
ruby 2.6.0dev (2018-03-30 trunk 63039) [x86_64-linux]
-e:1: [BUG] Segmentation fault at 0x0000000000000000
ruby 2.6.0dev (2018-03-30 trunk 63039) [x86_64-linux]

-- Control frame information -----------------------------------------------
(snip)

Updated by nagachika (Tomoyuki Chikanaga) about 6 years ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: REQUIRED

I don't think all of the changesets could be backported cleanly...
Anyway I set the Backport field for remembrance.

Updated by wanabe (_ wanabe) almost 6 years ago

ruby_2_5 is fixed at r66130 that is the backport of r63040.

$ ./miniruby -v -e 'RubyVM::InstructionSequence.compile("if false\nfoo bar: 1\nend").to_binary; p :done'
ruby 2.5.4p117 (2018-12-02 revision 66130) [x86_64-linux]
:done

$ git checkout HEAD~
Previous HEAD position was 0812ab5fec merge revision(s) 63040: [Backport #14553]
HEAD is now at 0fa65358e0 merge revision(s) 65365:

$ (make REVISION_FORCE=PHONY incs; make miniruby -j4) > /dev/null

$ ./miniruby -v -e 'RubyVM::InstructionSequence.compile("if false\nfoo bar: 1\nend").to_binary; p :done'
ruby 2.5.4p116 (2018-12-01 revision 66112) [x86_64-linux]
-e:1: [BUG] Segmentation fault at 0x0000000000000000
ruby 2.5.4p116 (2018-12-01 revision 66112) [x86_64-linux]

-- Control frame information -----------------------------------------------
(snip)
Actions #7

Updated by jeremyevans0 (Jeremy Evans) over 5 years ago

  • Status changed from Open to Closed
Actions #8

Updated by usa (Usaku NAKAMURA) over 5 years ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: REQUIRED to 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: DONE
Actions #9

Updated by jeremyevans0 (Jeremy Evans) over 5 years ago

  • Related to Bug #15392: Crash in RubyVM::InstructionSequence#to_binary added
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0