From: nobu@... Date: 2014-10-16T05:22:07+00:00 Subject: [ruby-core:65752] [ruby-trunk - Bug #10290] segfault when calling a lambda recursively after rescuing SystemStackError Issue #10290 has been updated by Nobuyoshi Nakada. Description updated I could reproduce it with gcc-4.9 on either Linux and OS X. On Linux, SIGSEGV seems masked after the first stack overflow occurred, and it seems working by enabling interrupts. ~~~diff diff --git c/eval.c i/eval.c index 3e4ea16..6bd6ac9 100644 --- c/eval.c +++ i/eval.c @@ -500,7 +500,6 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause) if (cause == Qundef) { cause = nocause ? Qnil : get_thread_errinfo(th); } - exc_setup_cause(mesg, cause); file = rb_sourcefile(); if (file) line = rb_sourceline(); @@ -526,6 +525,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause) set_backtrace(mesg, at); } } + exc_setup_cause(mesg, cause); if (!NIL_P(mesg)) { th->errinfo = mesg; diff --git c/signal.c i/signal.c index d3c7cb8..b939930 100644 --- c/signal.c +++ i/signal.c @@ -767,6 +767,7 @@ check_stack_overflow(const uintptr_t addr, const ucontext_t *ctx) * place. */ th->tag = th->tag->prev; } + rb_enable_interrupt(); ruby_thread_stack_overflow(th); } } ~~~ However, on OS X it makes the second stack overflow SIGILL, with no outputs. I have no idea what happens there. ---------------------------------------- Bug #10290: segfault when calling a lambda recursively after rescuing SystemStackError https://bugs.ruby-lang.org/issues/10290#change-49485 * Author: Jack Nagel * Status: Feedback * Priority: Normal * Assignee: * Category: * Target version: * ruby -v: ruby 2.1.3p242 (2014-09-19 revision 47629) [x86_64-darwin13.0] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- The following code segfaults on Ruby 2.1.3: ```ruby l = -> { l.() } begin l.() rescue SystemStackError l.() # segfault end ``` the issue does not occur on trunk. ---Files-------------------------------- ruby_2014-09-25-000925_haswell.log (46.4 KB) ruby_2014-09-25-001644_haswell.log (46.8 KB) -- https://bugs.ruby-lang.org/