Project

General

Profile

Bug #13425

Tracer.onにした状態でSystemStackErrorを発生させるとSegmentation fault

Added by masato_hi (Masato Hi) over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
[ruby-core:80662]

Description

Ruby2.4.0, 2.4.1の環境にて以下のコードのように SystemStackError: stack level too deep が発生するコードをTracerを有効化した状態で実行するとSegmentation faultや無限ループが発生する。

以下のコードは常にSegmentation faultを発生させる。

require 'tracer'

Tracer.on

class HogeError < StandardError
  def to_s
    message
  end
end

HogeError.new.to_s #=> Segmentation fault

以下のコードはフリーズ(おそらく何も出力しない無限ループ)する。
また、pry (0.10.4), pry-byebug (3.4.2)が入った環境でpry上で以下のコードを実行すると #0: を出力し続ける無限ループが発生する(添付画像参照)。

require 'tracer'

Tracer.on

def hoge
  hoge
end

hoge #=> freeze or infinite loop

Ruby 2.3.0及び2.3.1では発生していない。

実行環境

macOS 10.12, Debian 8.6


Files

Untitled.png (441 KB) Untitled.png pry上での実行結果 masato_hi (Masato Hi), 04/12/2017 05:27 AM

Related issues

Has duplicate Ruby master - Bug #13432: set_trace_funcにproc->is_from_method = TRUEのオブジェクトを渡し、SystemStackErrorを発生させるとRubyVMが停止するClosedActions

Associated revisions

Revision 38174633
Added by nobu (Nobuyoshi Nakada) over 2 years ago

thread.c: disable VM events when stack overflow

  • thread.c (ruby_thread_stack_overflow): disable VM events when stack overflow occurred; it causes another stack overflow again in making backtrace object, and crashes. [ruby-core:80662] [Bug #13425]

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

Revision 58334
Added by nobu (Nobuyoshi Nakada) over 2 years ago

thread.c: disable VM events when stack overflow

  • thread.c (ruby_thread_stack_overflow): disable VM events when stack overflow occurred; it causes another stack overflow again in making backtrace object, and crashes. [ruby-core:80662] [Bug #13425]

Revision 58334
Added by nobu (Nobuyoshi Nakada) over 2 years ago

thread.c: disable VM events when stack overflow

  • thread.c (ruby_thread_stack_overflow): disable VM events when stack overflow occurred; it causes another stack overflow again in making backtrace object, and crashes. [ruby-core:80662] [Bug #13425]

Revision 58334
Added by nobu (Nobuyoshi Nakada) over 2 years ago

thread.c: disable VM events when stack overflow

  • thread.c (ruby_thread_stack_overflow): disable VM events when stack overflow occurred; it causes another stack overflow again in making backtrace object, and crashes. [ruby-core:80662] [Bug #13425]

Revision 58346
Added by ko1 (Koichi Sasada) over 2 years ago

increase timeout seconds.

  • test/ruby/test_trace.rb (test_trace_stackoverflow): on some platforms this test fails because of timeout.

Revision 58349
Added by ko1 (Koichi Sasada) over 2 years ago

disable rewind hooks.

  • vm.c (hook_before_rewind): skip rewind hooks if err is SystemStackError
    because rewind hooks can cause stack overflow again and again.

  • thread.c (ruby_thread_stack_overflow): do not disable all hooks.
    Additionally, clearing ruby_vm_event_flags is not suitable way
    to disable hooks.

Revision 75b11469
Added by usa (Usaku NAKAMURA) about 2 years ago

merge revision(s) 58334,58346,58349: [Backport #13425] [Backport #13432]

    thread.c: disable VM events when stack overflow

    * thread.c (ruby_thread_stack_overflow): disable VM events when
      stack overflow occurred; it causes another stack overflow again
      in making backtrace object, and crashes.
      [ruby-core:80662] [Bug #13425]
    increase timeout seconds.

    * test/ruby/test_trace.rb (test_trace_stackoverflow): on some platforms
      this test fails because of timeout.

    disable rewind hooks.

    * vm.c (hook_before_rewind): skip rewind hooks if err is SystemStackError
      because rewind hooks can cause stack overflow again and again.

    * thread.c (ruby_thread_stack_overflow): do not disable all hooks.
      Additionally, clearing ruby_vm_event_flags is not suitable way
      to disable hooks.

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

Revision 59232
Added by usa (Usaku NAKAMURA) about 2 years ago

merge revision(s) 58334,58346,58349: [Backport #13425] [Backport #13432]

thread.c: disable VM events when stack overflow

* thread.c (ruby_thread_stack_overflow): disable VM events when
  stack overflow occurred; it causes another stack overflow again
  in making backtrace object, and crashes.
  [ruby-core:80662] [Bug #13425]
increase timeout seconds.

* test/ruby/test_trace.rb (test_trace_stackoverflow): on some platforms
  this test fails because of timeout.

disable rewind hooks.

* vm.c (hook_before_rewind): skip rewind hooks if err is SystemStackError
  because rewind hooks can cause stack overflow again and again.

* thread.c (ruby_thread_stack_overflow): do not disable all hooks.
  Additionally, clearing ruby_vm_event_flags is not suitable way
  to disable hooks.

Revision 5528c18d
Added by nagachika (Tomoyuki Chikanaga) about 2 years ago

merge revision(s) 58334,58346,58349: [Backport #13425] [Backport #13432]

    thread.c: disable VM events when stack overflow

    * thread.c (ruby_thread_stack_overflow): disable VM events when
      stack overflow occurred; it causes another stack overflow again
      in making backtrace object, and crashes.
      [ruby-core:80662] [Bug #13425]
    increase timeout seconds.

    * test/ruby/test_trace.rb (test_trace_stackoverflow): on some platforms
      this test fails because of timeout.

    disable rewind hooks.

    * vm.c (hook_before_rewind): skip rewind hooks if err is SystemStackError
      because rewind hooks can cause stack overflow again and again.

    * thread.c (ruby_thread_stack_overflow): do not disable all hooks.
      Additionally, clearing ruby_vm_event_flags is not suitable way
      to disable hooks.

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

Revision 59297
Added by nagachika (Tomoyuki Chikanaga) about 2 years ago

merge revision(s) 58334,58346,58349: [Backport #13425] [Backport #13432]

thread.c: disable VM events when stack overflow

* thread.c (ruby_thread_stack_overflow): disable VM events when
  stack overflow occurred; it causes another stack overflow again
  in making backtrace object, and crashes.
  [ruby-core:80662] [Bug #13425]
increase timeout seconds.

* test/ruby/test_trace.rb (test_trace_stackoverflow): on some platforms
  this test fails because of timeout.

disable rewind hooks.

* vm.c (hook_before_rewind): skip rewind hooks if err is SystemStackError
  because rewind hooks can cause stack overflow again and again.

* thread.c (ruby_thread_stack_overflow): do not disable all hooks.
  Additionally, clearing ruby_vm_event_flags is not suitable way
  to disable hooks.

History

#1

Updated by masato_hi (Masato Hi) over 2 years ago

  • ruby -v changed from 2.4.0, 2.4.1 to ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
#2

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r58334.


thread.c: disable VM events when stack overflow

  • thread.c (ruby_thread_stack_overflow): disable VM events when stack overflow occurred; it causes another stack overflow again in making backtrace object, and crashes. [ruby-core:80662] [Bug #13425]
#3

Updated by usa (Usaku NAKAMURA) over 2 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: UNKNOWN, 2.3: REQUIRED, 2.4: REQUIRED
#4

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Has duplicate Bug #13432: set_trace_funcにproc->is_from_method = TRUEのオブジェクトを渡し、SystemStackErrorを発生させるとRubyVMが停止する added

Updated by usa (Usaku NAKAMURA) about 2 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: UNKNOWN, 2.3: DONE, 2.4: REQUIRED

ruby_2_3 r59232 merged revision(s) 58334,58346,58349.

Updated by nagachika (Tomoyuki Chikanaga) about 2 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: DONE, 2.4: REQUIRED to 2.2: UNKNOWN, 2.3: DONE, 2.4: DONE

ruby_2_4 r59297 merged revision(s) 58334,58346,58349.

Also available in: Atom PDF