ruby-changes:46218
From: nobu <ko1@a...>
Date: Thu, 13 Apr 2017 16:38:27 +0900 (JST)
Subject: [ruby-changes:46218] nobu:r58334 (trunk): thread.c: disable VM events when stack overflow
nobu 2017-04-13 16:38:23 +0900 (Thu, 13 Apr 2017) New Revision: 58334 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58334 Log: 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] Modified files: trunk/test/ruby/test_trace.rb trunk/thread.c Index: test/ruby/test_trace.rb =================================================================== --- test/ruby/test_trace.rb (revision 58333) +++ test/ruby/test_trace.rb (revision 58334) @@ -59,4 +59,19 @@ class TestTrace < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_trace.rb#L59 a.any? {true} }.value, bug2722) end + + def test_trace_stackoverflow + assert_normal_exit("#{<<-"begin;"}\n#{<<~"end;"}") + begin; + require 'tracer' + class HogeError < StandardError + def to_s + message.upcase # disable tailcall optimization + end + end + Tracer.stdout = open(IO::NULL, "w") + Tracer.on + HogeError.new.to_s + end; + end end Index: thread.c =================================================================== --- thread.c (revision 58333) +++ thread.c (revision 58334) @@ -2169,6 +2169,7 @@ NORETURN(void ruby_thread_stack_overflow https://github.com/ruby/ruby/blob/trunk/thread.c#L2169 void ruby_thread_stack_overflow(rb_thread_t *th) { + ruby_vm_event_flags = 0; th->raised_flag = 0; #ifdef USE_SIGALTSTACK if (!rb_threadptr_during_gc(th)) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/