Project

General

Profile

Bug #13425

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

Added by masato_hi (Masato Hi) almost 3 years ago. Updated over 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
#1

Updated by masato_hi (Masato Hi) almost 3 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) almost 3 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) almost 3 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) over 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) over 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