Project

General

Profile

Actions

Bug #16695

closed

Stack consistency error when using the return value

Added by s4ichi (takamasa saichi) almost 5 years ago. Updated over 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin18]
[ruby-core:97538]

Description

Some versions of ruby occur Stack consistency error by following the reproduction code.

Reproduction code

x = false; y = (return until x unless x)

Per versions

  • 2.3.8
    • unexpected return (LocalJumpError)
  • 2.4.9
    • no problem
  • 2.5.7, 2.6.5, 2.7.0
    • Stack consistency error

Backtrace (2.7.0p0)

-e:1: [BUG] Stack consistency error (sp: 7, bp: 8)
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [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:0002 p:0020 s:0007 E:0004c0 EVAL   -e:1 [FINISH]
c:0001 p:0000 s:0003 E:002260 (none) [FINISH]

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

-- C level backtrace information -------------------------------------------
/Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib(rb_vm_bugreport+0x96) [0x1058bc6d6]
/Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib(rb_bug+0xd4) [0x1058c7fae]
/Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib(vm_stack_consistency_error.cold.1+0x2a) [0x1058ca09a]
/Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib(vm_stack_consistency_error+0x12) [0x1058b4cd2]
/Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib(vm_exec_core+0x43cf) [0x105897a3f]
/Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib(rb_vm_exec+0xa49) [0x1058aa529]
/Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib(rb_ec_exec_node+0xb6) [0x105715d06]
/Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib(ruby_run_node+0x55) [0x105715c05]
/Users/takamasa-saichi/.rbenv/versions/2.7.0/bin/ruby(main+0x5d) [0x105673f0d]

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

* Loaded script: -e

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 ruby2_keywords.rb
    5 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
    6 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
    7 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/rbconfig.rb
    8 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/compatibility.rb
    9 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/defaults.rb
   10 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/deprecate.rb
   11 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/errors.rb
   12 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/version.rb
   13 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/requirement.rb
   14 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/platform.rb
   15 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/basic_specification.rb
   16 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/stub_specification.rb
   17 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/util.rb
   18 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/text.rb
   19 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/user_interaction.rb
   20 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/specification_policy.rb
   21 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/util/list.rb
   22 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/specification.rb
   23 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/exceptions.rb
   24 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/bundler_version_finder.rb
   25 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/dependency.rb
   26 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/core_ext/kernel_gem.rb
   27 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/monitor.bundle
   28 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/monitor.rb
   29 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb
   30 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/core_ext/kernel_warn.rb
   31 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems.rb
   32 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/path_support.rb
   33 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean/version.rb
   34 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean/core_ext/name_error.rb
   35 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean/levenshtein.rb
   36 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean/jaro_winkler.rb
   37 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean/spell_checker.rb
   38 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
   39 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
   40 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean/spell_checkers/name_error_checkers.rb
   41 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean/spell_checkers/method_name_checker.rb
   42 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean/spell_checkers/key_error_checker.rb
   43 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean/spell_checkers/null_checker.rb
   44 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean/formatters/plain_formatter.rb
   45 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean/tree_spell_checker.rb
   46 /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/did_you_mean.rb

* Process memory map:

105673000-105674000 r-x /Users/takamasa-saichi/.rbenv/versions/2.7.0/bin/ruby
105674000-105675000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/bin/ruby
105675000-105676000 r-- /Users/takamasa-saichi/.rbenv/versions/2.7.0/bin/ruby
105676000-105678000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib
105678000-105679000 r-- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib
105679000-10596b000 r-x /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib
10596b000-105972000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib
105972000-10598a000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib
10598a000-105a73000 r-- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib
105a73000-105a74000 r-- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105a74000-105a75000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105a75000-105a76000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105a76000-105a7c000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105a7c000-105a7d000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105a7d000-105a7e000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105a7e000-105a84000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105a84000-105a85000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105a85000-105a86000 r-- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105a86000-105ac6000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105ac6000-105ae1000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105ae1000-105be1000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105be1000-105be3000 r-x /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105be3000-105be4000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105be4000-105be5000 r-- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/encdb.bundle
105be5000-105be6000 r-x /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/monitor.bundle
105be6000-105be7000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/monitor.bundle
105be7000-105be8000 r-- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/monitor.bundle
105be8000-107be8000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107be8000-107bfc000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107bfc000-107c14000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107c14000-107c15000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107c15000-107cb6000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107cb6000-107cb7000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107cb7000-107d58000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107d58000-107d59000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107d59000-107dfa000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107dfa000-107dfb000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107dfb000-107e9c000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107e9c000-107e9d000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107e9d000-107f3e000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107f3e000-107f3f000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107f3f000-107fe0000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107fe0000-107fe1000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
107fe1000-108082000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108082000-108083000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108083000-108124000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108124000-108125000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108125000-1081c6000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
1081c6000-1081c7000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
1081c7000-108268000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108268000-108269000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108269000-10830a000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
10830a000-10830b000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
10830b000-1083ac000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
1083ac000-1083ad000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
1083ad000-10844e000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
10844e000-10844f000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
10844f000-1084f0000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
1084f0000-1084f1000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
1084f1000-108592000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108592000-108593000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108593000-108634000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108634000-108635000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108635000-1086d6000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
1086d6000-1086d7000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
1086d7000-108778000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108778000-108779000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108779000-10881a000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
10881a000-10881b000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
10881b000-1088bc000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
1088bc000-1088bd000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
1088bd000-10895e000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
10895e000-10895f000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
10895f000-108a00000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108a00000-108a01000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108a01000-108aa2000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108aa2000-108aa3000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108aa3000-108b44000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108b44000-108b45000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108b45000-108be6000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108be6000-108be7000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108be7000-108c88000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108c88000-108c89000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108c89000-108d2a000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108d2a000-108d2b000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108d2b000-108dcc000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108dcc000-108dcd000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108dcd000-108e6e000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108e6e000-108e6f000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108e6f000-108f10000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108f10000-108f11000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108f11000-108fb2000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108fb2000-108fb3000 --- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
108fb3000-109054000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
109054000-10906c000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
10906c000-10906e000 r-x /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
10906e000-10906f000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
10906f000-109070000 r-- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/ruby/2.7.0/x86_64-darwin18/enc/trans/transdb.bundle
109070000-10907f000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/bin/ruby
10907f000-109097000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/bin/ruby
109097000-1090b4000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/bin/ruby
1090b4000-1090ed000 rw- /Users/takamasa-saichi/.rbenv/versions/2.7.0/bin/ruby
1090ed000-1090f0000 r-- /Users/takamasa-saichi/.rbenv/versions/2.7.0/bin/ruby
1090f0000-1094d2000 r-- /Users/takamasa-saichi/.rbenv/versions/2.7.0/lib/libruby.2.7.dylib
11382c000-113897000 r-x /usr/lib/dyld
113897000-11389c000 rw- /usr/lib/dyld
11389c000-1138d0000 rw- /usr/lib/dyld
1138d0000-1138f7000 r-- /usr/lib/dyld
7000025f1000-7000025f2000 --- /usr/lib/dyld
7000025f2000-700002674000 rw- /usr/lib/dyld
7fce95400000-7fce95500000 rw- /usr/lib/dyld
7fce95500000-7fce95600000 rw- /usr/lib/dyld
7fce95600000-7fce95700000 rw- /usr/lib/dyld
7fce95700000-7fce95800000 rw- /usr/lib/dyld
7fce95800000-7fce96000000 rw- /usr/lib/dyld
7fce96000000-7fce96800000 rw- /usr/lib/dyld
7fce96800000-7fce96900000 rw- /usr/lib/dyld
7fce96900000-7fce96a00000 rw- /usr/lib/dyld
7fce96a00000-7fce96b00000 rw- /usr/lib/dyld
7fce96b00000-7fce96c00000 rw- /usr/lib/dyld
7fce96c00000-7fce96d00000 rw- /usr/lib/dyld
7fce97000000-7fce97800000 rw- /usr/lib/dyld
7fce97800000-7fce98000000 rw- /usr/lib/dyld
7fce98000000-7fce98800000 rw- /usr/lib/dyld
7fce98800000-7fce99000000 rw- /usr/lib/dyld
7fce99000000-7fce99800000 rw- /usr/lib/dyld
7ffee658d000-7ffee9d8d000 --- /usr/lib/dyld
7ffee9d8d000-7ffeea58d000 rw- /usr/lib/dyld
7fff00000000-7fff80000000 r-- /usr/lib/dyld
7fff80000000-7fff95f59000 r-- /usr/lib/dyld
7fff95f59000-7fff96000000 rw- /usr/lib/dyld
7fff96000000-7fff9c000000 r-- /usr/lib/dyld
7fff9c000000-7fff9c200000 rw- /usr/lib/dyld
7fff9c200000-7fff9c800000 r-- /usr/lib/dyld
7fff9c800000-7fff9ca00000 rw- /usr/lib/dyld
7fff9ca00000-7fff9cc00000 rw- /usr/lib/dyld
7fff9cc00000-7fff9ce00000 rw- /usr/lib/dyld
7fff9ce00000-7fff9d000000 rw- /usr/lib/dyld
7fff9d000000-7fff9d200000 rw- /usr/lib/dyld
7fff9d200000-7fff9d400000 rw- /usr/lib/dyld
7fff9d400000-7fff9e400000 r-- /usr/lib/dyld
7fff9e400000-7fff9e600000 rw- /usr/lib/dyld
7fff9e600000-7fffa0200000 r-- /usr/lib/dyld
7fffa0200000-7fffa0400000 rw- /usr/lib/dyld
7fffa0400000-7fffa1200000 r-- /usr/lib/dyld
7fffa1200000-7fffa1400000 rw- /usr/lib/dyld
7fffa1400000-7fffa3600000 r-- /usr/lib/dyld
7fffa3600000-7fffa3800000 rw- /usr/lib/dyld
7fffa3800000-7fffa3a00000 rw- /usr/lib/dyld
7fffa3a00000-7fffa3c00000 rw- /usr/lib/dyld
7fffa3c00000-7fffa3e00000 rw- /usr/lib/dyld
7fffa3e00000-7fffa4000000 rw- /usr/lib/dyld
7fffa4000000-7fffa402e000 rw- /usr/lib/dyld
7fffa402e000-7fffc0000000 r-- /usr/lib/dyld
7fffc0000000-7fffffe00000 r-- /usr/lib/dyld
7fffffe00000-7fffffe01000 r-- /usr/lib/dyld
7ffffff03000-7ffffff04000 r-x /usr/lib/dyld
[IMPORTANT]
Don't forget to include the Crash Report log file under
DiagnosticReports directory in bug reports.

Files

ruby_2020-03-18-201902.crash (37.9 KB) ruby_2020-03-18-201902.crash s4ichi (takamasa saichi), 03/18/2020 11:22 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #14273: Stack Consistency Error from return in loopClosedActions

Updated by nobu (Nobuyoshi Nakada) almost 5 years ago

  • Backport changed from 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN to 2.5: REQUIRED, 2.6: REQUIRED, 2.7: REQUIRED

Thank you for the interesting report.
I confirmed that this has existed since 1.9.1 at least, by wrapping in a method.

$ ruby1.9 -e 'def f;x = false; y = (return until x unless x);end;f'
-e:1: [BUG] Stack consistency error (sp: 10, bp: 11)
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-darwin19.0.0]

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

This is due to a bug in the optimizer. Adding return COMPILE_OK; to the top of iseq_peephole_optimize fixes the problem.

Instructions before (optimization/broken):

== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,52)> (catch: FALSE)
0000 definemethod                           :f, f                     (   1)[Li]
0003 putself
0004 opt_send_without_block                 <calldata!mid:f, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0006 leave

== disasm: #<ISeq:f@-e:1 (1,0)-(1,50)> (catch: FALSE)
== catch table
| catch type: break  st: 0017 ed: 0025 sp: 0001 cont: 0025
| catch type: next   st: 0017 ed: 0025 sp: 0001 cont: 0014
| catch type: redo   st: 0017 ed: 0025 sp: 0001 cont: 0017
|------------------------------------------------------------------------
local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 2] x@0        [ 1] y@1
0000 putobject                              false                     (   1)[LiCa]
0002 setlocal_WC_0                          x@0
0004 getlocal_WC_0                          x@0
0006 branchunless                           20
0008 putnil
0009 jump                                   26
0011 jump                                   20
0013 putnil
0014 pop
0015 jump                                   20
0017 pop
0018 putnil
0019 leave                                  [Re]
0020 getlocal_WC_0                          x@0
0022 branchunless                           17
0024 putnil
0025 nop
0026 dup                                                              (   1)
0027 setlocal_WC_0                          y@1
0029 leave                                  [Re]

Instructions after (no optimization/working):

== disasm: #<ISeq:<main>@t/t29.rb:1 (1,0)-(5,1)> (catch: FALSE)
0000 definemethod                           :f, f                     (   1)[Li]
0003 putself                                                          (   5)[Li]
0004 opt_send_without_block                 <calldata!mid:f, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0006 leave

== disasm: #<ISeq:f@t/t29.rb:1 (1,0)-(4,3)> (catch: FALSE)
== catch table
| catch type: break  st: 0019 ed: 0028 sp: 0000 cont: 0028
| catch type: next   st: 0019 ed: 0028 sp: 0000 cont: 0016
| catch type: redo   st: 0019 ed: 0028 sp: 0000 cont: 0019
|------------------------------------------------------------------------
local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 2] x@0        [ 1] y@1
0000 putobject                              false                     (   2)[LiCa]
0002 setlocal_WC_0                          x@0
0004 getlocal_WC_0                          x@0                       (   3)[Li]
0006 branchunless                           13
0008 jump                                   10
0010 putnil
0011 jump                                   29
0013 jump                                   21
0015 putnil
0016 pop
0017 jump                                   21
0019 putnil
0020 leave                                  [Re]
0021 getlocal_WC_0                          x@0
0023 branchunless                           19
0025 jump                                   27
0027 putnil
0028 nop
0029 dup                                                              (   3)
0030 setlocal_WC_0                          y@1
0032 leave                                                            (   4)[Re]

One thing that jumps out at me is the optimized version uses pop between jump and putnil (instruction 0017). That could be why sp is lower than bp. However, I don't have that much experience reading iseq instructions, so that's more of a guess than anything.

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

Through trial and error, I've determined this is caused by the branchif/branchnil/branchunless optimization, self described as a super nasty hack. I've submitted a pull request to disable this optimization (https://github.com/ruby/ruby/pull/3150), and think it should be committed until someone can debug the optimization and fix it (assuming it passes CI).

Updated by wanabe (_ wanabe) over 4 years ago

How about adjust sp in dead code that is after jump?

diff --git a/compile.c b/compile.c
index dfa3802579..85cbd42893 100644
--- a/compile.c
+++ b/compile.c
@@ -5386,6 +5386,9 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int
                branches);
            end_label = NEW_LABEL(line);
            ADD_INSNL(then_seq, line, jump, end_label);
+            if (!popped) {
+                ADD_INSN(then_seq, line, pop);
+            }
        }
        ADD_SEQ(ret, then_seq);
     }

Updated by wanabe (_ wanabe) over 4 years ago

Oops, my patch is duplicated at 43c1eb440a7 == r61618 partially so I must revert it at first.

diff --git a/compile.c b/compile.c
index dfa3802579..2766e985c3 100644
--- a/compile.c
+++ b/compile.c
@@ -2836,7 +2836,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
 	    goto again;
 	}
         else if (IS_INSN_ID(diobj, leave)) {
-	    INSN *pop;
 	    /*
 	     *  jump LABEL
 	     *  ...
@@ -2844,7 +2843,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
 	     *  leave
 	     * =>
 	     *  leave
-	     *  pop
 	     *  ...
 	     * LABEL:
 	     *  leave
@@ -2854,9 +2852,6 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
             iobj->insn_id = BIN(leave);
 	    iobj->operand_size = 0;
 	    iobj->insn_info = diobj->insn_info;
-	    /* adjust stack depth */
-	    pop = new_insn_body(iseq, diobj->insn_info.line_no, BIN(pop), 0);
-            ELEM_INSERT_NEXT(&iobj->link, &pop->link);
 	    goto again;
 	}
         else if (IS_INSN(iobj->link.prev) &&
@@ -5386,6 +5381,9 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int
 		branches);
 	    end_label = NEW_LABEL(line);
 	    ADD_INSNL(then_seq, line, jump, end_label);
+            if (!popped) {
+                ADD_INSN(then_seq, line, pop);
+            }
 	}
 	ADD_SEQ(ret, then_seq);
     }

Actions #6

Updated by wanabe (_ wanabe) over 4 years ago

  • Related to Bug #14273: Stack Consistency Error from return in loop added

Updated by wanabe (_ wanabe) over 4 years ago

Maybe there are some potential issues.

$ ruby -v -e 'RubyVM::InstructionSequence.compile("def f; return 1 unless true or any; end", peephole_optimization: false).eval'
ruby 2.8.0dev (2020-08-02T03:05:19Z wanabe/master ac69849e49) [x86_64-linux]
-- raw disasm--------
   trace: 8
   trace: 1
   0000 jump                 <L000>                                      (   1)
*  0002 branchunless         <L001>                                      (   1)
   0004 jump                 <L000>                                      (   1)
 <L000> [sp: 0]
   0006 putnil                                                           (   1)
   0007 jump                 <L003>                                      (   1)
 <L001> [sp: -1]
   0009 putobject_INT2FIX_1_                                             (   1)
 <L003> [sp: -1]
   trace: 10
   0010 leave                                                            (   1)
---------------------
<compiled>: <compiled>:1: argument stack underflow (-1) (SyntaxError)
$ ruby -v -e 'def f; return 1 if false and any; nil; end'
ruby 2.8.0dev (2020-08-02T03:05:19Z wanabe/master ac69849e49) [x86_64-linux]
-- raw disasm--------
   trace: 8
   trace: 1
   0000 jump                 <L001>                                      (   1)
*  0002 branchunless         <L001>                                      (   1)
 <L003> [sp: -1]
   adjust: [label: -1]
   0004 putobject_INT2FIX_1_                                             (   1)
   trace: 10
   0005 leave                                                            (   1)
   adjust: [label: 3]
 <L001> [sp: 0]
   0006 putnil                                                           (   1)
   trace: 10
   0007 leave                                                            (   1)
---------------------
-e: -e:1: argument stack underflow (-1) (SyntaxError)

I sent Pull Request to fix some issues I found.
https://github.com/ruby/ruby/pull/3402

Updated by wanabe (_ wanabe) about 4 years ago

I rewrited the patch https://github.com/ruby/ruby/pull/3445 on 2020-08-22.
I would appreciate it if someone could review this.

Actions #9

Updated by wanabe (_ wanabe) about 4 years ago

  • Status changed from Open to Closed

Applied in changeset git|ce7a053475cbebfb2f3e5ed6614e0ba631541917.


Adjust sp for x = false; y = (return until x unless x) [Bug #16695]

Updated by nagachika (Tomoyuki Chikanaga) almost 4 years ago

  • Backport changed from 2.5: REQUIRED, 2.6: REQUIRED, 2.7: REQUIRED to 2.5: REQUIRED, 2.6: REQUIRED, 2.7: DONE

ruby_2_7 c271c7a225c6175f56f00b785e3034cb4a2b7658 merged revision(s) ce7a053475cbebfb2f3e5ed6614e0ba631541917,1cbb1f1720127b0b34b38c77e27b51b182008699.

Updated by usa (Usaku NAKAMURA) over 3 years ago

  • Backport changed from 2.5: REQUIRED, 2.6: REQUIRED, 2.7: DONE to 2.5: REQUIRED, 2.6: DONE, 2.7: DONE

backported into ruby_2_6 at r67925

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0