[MacRuby] #527: Segmentation fault when stack overflows
#527: Segmentation fault when stack overflows -------------------------------------+-------------------------------------- Reporter: haruki.zaemon@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: stack overflow segfault -------------------------------------+-------------------------------------- irb --> def a(n); n == 0 ? "DONE" : b(n - 1); end irb --> def b(n); n == 0 ? "DONE" : a(n - 1); end irb --> a(10000) Segmentation fault -- Ticket URL: <http://www.macruby.org/trac/ticket/527> MacRuby <http://macruby.org/>
#527: Segmentation fault when stack overflows -------------------------------------+-------------------------------------- Reporter: haruki.zaemon@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: stack overflow segfault -------------------------------------+-------------------------------------- Comment(by conradwt@…): This is a very common case in both Ruby 1.8.x and 1.9.x. In Ruby 1.9.1, the max stack is set by the interpreter. This may or may not be the case in MacRuby. -- Ticket URL: <http://www.macruby.org/trac/ticket/527#comment:1> MacRuby <http://macruby.org/>
#527: Segmentation fault when stack overflows -------------------------------------+-------------------------------------- Reporter: haruki.zaemon@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: stack overflow segfault -------------------------------------+-------------------------------------- Description changed by lsansonetti@…: Old description:
irb --> def a(n); n == 0 ? "DONE" : b(n - 1); end irb --> def b(n); n == 0 ? "DONE" : a(n - 1); end irb --> a(10000) Segmentation fault
New description: {{{ irb --> def a(n); n == 0 ? "DONE" : b(n - 1); end irb --> def b(n); n == 0 ? "DONE" : a(n - 1); end irb --> a(10000) Segmentation fault }}} -- -- Ticket URL: <http://www.macruby.org/trac/ticket/527#comment:2> MacRuby <http://macruby.org/>
#527: Segmentation fault when stack overflows -------------------------------------+-------------------------------------- Reporter: haruki.zaemon@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: stack overflow segfault -------------------------------------+-------------------------------------- Comment(by lsansonetti@…): I guess we should not crash and raise an exception instead. -- Ticket URL: <http://www.macruby.org/trac/ticket/527#comment:3> MacRuby <http://macruby.org/>
#527: Segmentation fault when stack overflows -------------------------------------+-------------------------------------- Reporter: haruki.zaemon@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: stack overflow segfault -------------------------------------+-------------------------------------- Comment(by conradwt@…): Yes, I agree that MacRuby should generate an exception. For example, in Ruby 1.9.1/1.9.2, the following is generated: {{{ $ ruby stack-overflow.rb stack-overflow.rb:6:in `b': stack level too deep (SystemStackError) from stack-overflow.rb:2:in `a' from stack-overflow.rb:6:in `b' from stack-overflow.rb:2:in `a' from stack-overflow.rb:6:in `b' from stack-overflow.rb:2:in `a' from stack-overflow.rb:6:in `b' from stack-overflow.rb:2:in `a' from stack-overflow.rb:6:in `b' ... 8718 levels... from stack-overflow.rb:2:in `a' from stack-overflow.rb:6:in `b' from stack-overflow.rb:2:in `a' from stack-overflow.rb:9:in `<main>' }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/527#comment:4> MacRuby <http://macruby.org/>
#527: Segmentation fault when stack overflows -------------------------------------+-------------------------------------- Reporter: haruki.zaemon@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: stack overflow segfault -------------------------------------+-------------------------------------- Comment(by haruki.zaemon@…): Replying to [comment:1 conradwt@…]:
This is a very common case in both Ruby 1.8.x and 1.9.x. In Ruby 1.9.1, the max stack is set by the interpreter. This may or may not be the case in MacRuby.
Sorry, perhaps I should have been more specific: I think an exception should be raised (as is done in MRI and Rubinius) rather than a segmentation fault. -- Ticket URL: <http://www.macruby.org/trac/ticket/527#comment:5> MacRuby <http://macruby.org/>
#527: Segmentation fault when stack overflows -------------------------------------+-------------------------------------- Reporter: haruki.zaemon@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: stack overflow segfault -------------------------------------+-------------------------------------- Comment(by martinlagardette@…): Updating status of the bug following #822: It could be possible for MacRuby to handle stack overflow, by handling the stack overflow signal in an alternate stack (allocated with `sigaltstack`). The reasons it is not currently in MacRuby are - Handling the stack overflow signal (I believe it is SIGSEV) messes up the stack and is not good for crash trace analyzers (See r4077) - If we raise in the alt stack, I'm not sure there's a way to catch it in the main thread, meaning a SystemStackError would stop the program, and would not be catchable -- Ticket URL: <http://www.macruby.org/trac/ticket/527#comment:7> MacRuby <http://macruby.org/>
#527: Segmentation fault when stack overflows -------------------------------------+-------------------------------------- Reporter: haruki.zaemon@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: stack overflow segfault -------------------------------------+-------------------------------------- Comment(by lsansonetti@…): Catching the signal wouldnt help here as I'm pretty sure it's already too late to do anything, also, sending an exception from a signal handler isn't likely to work too. What we could do instead is keep a counter in the dispatch cache. However I don't think this is a critical issue. -- Ticket URL: <http://www.macruby.org/trac/ticket/527#comment:8> MacRuby <http://macruby.org/>
#527: Segmentation fault when stack overflows -------------------------------------+-------------------------------------- Reporter: haruki.zaemon@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: stack overflow segfault -------------------------------------+-------------------------------------- Comment(by martinlagardette@…):
"Catching the signal wouldnt help here as I'm pretty sure it's already too late to do anything"
That's actually what `sigaltstack` is for, it allocates a stack just for handling the signal. But yeah, raising from there is likely to fail. And I also agree that it's not a critical issue at all, I just wanted to update the status of the bug so that people know why it's not fixed yet :-) -- Ticket URL: <http://www.macruby.org/trac/ticket/527#comment:9> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby