Project

General

Profile

Bug #14273

Stack Consistency Error from return in loop

Added by ccutrer (Cody Cutrer) over 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
[ruby-core:84589]

Description

def foo(x)
  unless x
    while !x
      return nil
    end
  end
end
foo(nil)
(irb):18: [BUG] Stack consistency error (sp: 100, bp: 101)
ruby 2.5.0p0 (2017-12-25 revision 61468) [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:0020 p:0013 s:0100 e:000100 ------ (irb):18
c:0019 p:0005 s:0096 e:000095 EVAL   (irb):22 [FINISH]
c:0018 p:---- s:0093 e:000092 CFUNC  :eval
c:0017 p:0021 s:0085 e:000084 METHOD /Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/workspace.rb:85
c:0016 p:0021 s:0077 e:000075 METHOD /Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/context.rb:380
c:0015 p:0017 s:0070 e:000069 BLOCK  /Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:491
c:0014 p:0025 s:0060 e:000059 METHOD /Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:621
c:0013 p:0008 s:0054 e:000053 BLOCK  /Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:488
c:0012 p:0102 s:0049 e:000048 BLOCK  /Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ruby-lex.rb:246 [FINISH]
c:0011 p:---- s:0045 e:000044 CFUNC  :loop
c:0010 p:0006 s:0041 e:000040 BLOCK  /Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ruby-lex.rb:232 [FINISH]
c:0009 p:---- s:0038 e:000037 CFUNC  :catch
c:0008 p:0012 s:0033 e:000032 METHOD /Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ruby-lex.rb:231
c:0007 p:0029 s:0029 E:000690 METHOD /Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:487
c:0006 p:0005 s:0025 e:000024 BLOCK  /Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:428 [FINISH]
c:0005 p:---- s:0022 e:000021 CFUNC  :catch
c:0004 p:0063 s:0017 E:0007f8 METHOD /Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:427
c:0003 p:0102 s:0012 e:000011 METHOD /Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:383
c:0002 p:0019 s:0006 e:000005 EVAL   /Users/cody/.rubies/ruby-2.5.0/bin/irb:11 [FINISH]
c:0001 p:0000 s:0003 E:0000d0 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
/Users/cody/.rubies/ruby-2.5.0/bin/irb:11:in `<main>'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:383:in `start'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:427:in `run'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:427:in `catch'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:428:in `block in run'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:487:in `eval_input'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ruby-lex.rb:231:in `each_top_level_statement'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ruby-lex.rb:231:in `catch'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ruby-lex.rb:232:in `block in each_top_level_statement'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ruby-lex.rb:232:in `loop'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/ruby-lex.rb:246:in `block (2 levels) in each_top_level_statement'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:488:in `block in eval_input'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:621:in `signal_status'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb.rb:491:in `block (2 levels) in eval_input'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/context.rb:380:in `evaluate'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/workspace.rb:85:in `evaluate'
/Users/cody/.rubies/ruby-2.5.0/lib/ruby/2.5.0/irb/workspace.rb:85:in `eval'
(irb):22:in `irb_binding'
(irb):18:in `foo'

-- C level backtrace information -------------------------------------------
0   ruby                                0x0000000103409dd7 rb_vm_bugreport + 135
1   ruby                                0x000000010328eca8 rb_bug + 472
2   ruby                                0x00000001033e78d3 vm_exec_core + 15955
3   ruby                                0x00000001033f7b8e vm_exec + 142
4   ruby                                0x0000000103405fda eval_string_with_cref + 1418
5   ruby                                0x00000001033f385e rb_f_eval + 334
6   ruby                                0x00000001033fd2be vm_call_cfunc + 286
7   ruby                                0x00000001033e6a24 vm_exec_core + 12196
8   ruby                                0x00000001033f7b8e vm_exec + 142
9   ruby                                0x00000001034052b4 invoke_block_from_c_bh + 372
10  ruby                                0x0000000103406323 loop_i + 35
11  ruby                                0x00000001032991a7 rb_rescue2 + 311
12  ruby                                0x00000001033fd2be vm_call_cfunc + 286
13  ruby                                0x00000001033e5f84 vm_exec_core + 9476
14  ruby                                0x00000001033f7b8e vm_exec + 142
15  ruby                                0x00000001034052b4 invoke_block_from_c_bh + 372
16  ruby                                0x00000001034062be catch_i + 78
17  ruby                                0x00000001033f49dd vm_catch_protect + 173
18  ruby                                0x00000001033f5092 rb_f_catch + 66
19  ruby                                0x00000001033fd2be vm_call_cfunc + 286
20  ruby                                0x00000001033e5f84 vm_exec_core + 9476
21  ruby                                0x00000001033f7b8e vm_exec + 142
22  ruby                                0x00000001034052b4 invoke_block_from_c_bh + 372
23  ruby                                0x00000001034062be catch_i + 78
24  ruby                                0x00000001033f49dd vm_catch_protect + 173
25  ruby                                0x00000001033f5092 rb_f_catch + 66
26  ruby                                0x00000001033fd2be vm_call_cfunc + 286
27  ruby                                0x00000001033e5f84 vm_exec_core + 9476
28  ruby                                0x00000001033f7b8e vm_exec + 142
29  ruby                                0x00000001032989d1 ruby_exec_internal + 177
30  ruby                                0x00000001032988c8 ruby_run_node + 56
31  ruby                                0x000000010321e11f main + 79

Related issues

Has duplicate Ruby trunk - Bug #14402: Crash and coredump (Stack consistency error) on ruby 2.5.0ClosedActions
Has duplicate Ruby trunk - Bug #14403: Crash and coredump (Stack consistency error) on ruby 2.5.0ClosedActions

Associated revisions

Revision 61587
Added by nobu (Nobuyoshi Nakada) over 1 year ago

compile.c: next label

  • compile.c (compile_next): label for jump to the end of block is removable.

Revision 61617
Added by nobu (Nobuyoshi Nakada) over 1 year ago

compile.c: remove more unreachable chunk

  • compile.c (remove_unreachable_chunk): remove beyond labels to be removed.

Revision 43c1eb44
Added by nobu (Nobuyoshi Nakada) over 1 year ago

compile.c: fix stack consistency error

  • compile.c (iseq_peephole_optimize): fix stack consistency error from return in loop, by adding extra pop when replacing jump with leave, which is never reached but needed to adjust sp calculation. [ruby-core:84589] [Bug #14273]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 61618
Added by nobu (Nobuyoshi Nakada) over 1 year ago

compile.c: fix stack consistency error

  • compile.c (iseq_peephole_optimize): fix stack consistency error from return in loop, by adding extra pop when replacing jump with leave, which is never reached but needed to adjust sp calculation. [ruby-core:84589] [Bug #14273]

Revision 61618
Added by nobu (Nobuyoshi Nakada) over 1 year ago

compile.c: fix stack consistency error

  • compile.c (iseq_peephole_optimize): fix stack consistency error from return in loop, by adding extra pop when replacing jump with leave, which is never reached but needed to adjust sp calculation. [ruby-core:84589] [Bug #14273]

Revision 38aa1376
Added by naruse (Yui NARUSE) over 1 year ago

merge revision(s) 61617,61618: [Backport #14273]

    compile.c: remove more unreachable chunk

    * compile.c (remove_unreachable_chunk): remove beyond labels to be
      removed.

    compile.c: fix stack consistency error

    * compile.c (iseq_peephole_optimize): fix stack consistency error
      from return in loop, by adding extra `pop` when replacing `jump`
      with `leave`, which is never reached but needed to adjust sp
      calculation.  [ruby-core:84589] [Bug #14273]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62426
Added by naruse (Yui NARUSE) over 1 year ago

merge revision(s) 61617,61618: [Backport #14273]

compile.c: remove more unreachable chunk

* compile.c (remove_unreachable_chunk): remove beyond labels to be
  removed.

compile.c: fix stack consistency error

* compile.c (iseq_peephole_optimize): fix stack consistency error
  from return in loop, by adding extra `pop` when replacing `jump`
  with `leave`, which is never reached but needed to adjust sp
  calculation.  [ruby-core:84589] [Bug #14273]

Revision 2d414cb1
Added by naruse (Yui NARUSE) about 1 year ago

merge revision(s) 61587,61617,61618: [Backport #14273]

    compile.c: next label

    * compile.c (compile_next): label for jump to the end of block is
      removable.

    compile.c: remove more unreachable chunk

    * compile.c (remove_unreachable_chunk): remove beyond labels to be
      removed.

    compile.c: fix stack consistency error

    * compile.c (iseq_peephole_optimize): fix stack consistency error
      from return in loop, by adding extra `pop` when replacing `jump`
      with `leave`, which is never reached but needed to adjust sp
      calculation.  [ruby-core:84589] [Bug #14273]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62911
Added by naruse (Yui NARUSE) about 1 year ago

merge revision(s) 61587,61617,61618: [Backport #14273]

compile.c: next label

* compile.c (compile_next): label for jump to the end of block is
  removable.

compile.c: remove more unreachable chunk

* compile.c (remove_unreachable_chunk): remove beyond labels to be
  removed.

compile.c: fix stack consistency error

* compile.c (iseq_peephole_optimize): fix stack consistency error
  from return in loop, by adding extra `pop` when replacing `jump`
  with `leave`, which is never reached but needed to adjust sp
  calculation.  [ruby-core:84589] [Bug #14273]

History

#1

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Status changed from Open to Closed

Applied in changeset trunk|r61618.


compile.c: fix stack consistency error

  • compile.c (iseq_peephole_optimize): fix stack consistency error from return in loop, by adding extra pop when replacing jump with leave, which is never reached but needed to adjust sp calculation. [ruby-core:84589] [Bug #14273]
#2

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

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

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Has duplicate Bug #14402: Crash and coredump (Stack consistency error) on ruby 2.5.0 added
#4

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Has duplicate Bug #14403: Crash and coredump (Stack consistency error) on ruby 2.5.0 added

Updated by naruse (Yui NARUSE) over 1 year ago

  • Backport changed from 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONE

ruby_2_5 r62426 merged revision(s) 61617,61618.

Updated by naruse (Yui NARUSE) over 1 year ago

  • Backport changed from 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONE to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED

reverted ruby_2_5 r62426. it caused test failure

Updated by jacobevelyn (Jacob Evelyn) about 1 year ago

naruse (Yui NARUSE) wrote:

reverted ruby_2_5 r62426. it caused test failure

Forgive me if I'm misunderstanding, but should this be reopened if the Ruby 2.5 backport was reverted?

#8

Updated by jacobevelyn (Jacob Evelyn) about 1 year ago

  • Status changed from Closed to Open

Updated by naruse (Yui NARUSE) about 1 year ago

  • Status changed from Open to Closed

Backporting is managed with "Backport" field.
Status: Closed is expected one.

Updated by jacobevelyn (Jacob Evelyn) about 1 year ago

Ah okay sorry, thanks!

Updated by nobu (Nobuyoshi Nakada) about 1 year ago

  • Description updated (diff)

Added r61587 to associated revisions.

Updated by naruse (Yui NARUSE) about 1 year ago

  • Backport changed from 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONE

ruby_2_5 r62911 merged revision(s) 61587,61617,61618.

Also available in: Atom PDF