Issue #10460 has been updated by Arne Brasseur.


That makes sense, I agree with your point. Having a nicer error message on broken code isn't a big deal.

There is an actual use case beyond "a nicer error message" though.

Me and others make heavy use of mutation testing with Mutant (https://github.com/mbj/mutant/). Mutant changes the ruby code in many different ways, and then checks if your tests fail. The result is you can have much more confidence in your code and your tests. Once you get used to mutation testing it's hard to go without.

Mutant will often generate "broken" code, that's how it works, so endless recursion could be the result. It needs to be able to detect somehow that things go wrong. A segfault is actually not the biggest problem. Mutant forks off workers, so if the worker dies it can assume something went wrong. Sometimes the code in this ticket also causes Ruby to get stuck in a futex. In that case the worker is "stuck" and Mutant becomes unusable.

Maybe not everybody agrees on the usefulness of mutation testing, or if that is a valid use case for MRI. I just wanted to clarify why I filed this ticket. Actually the locking up is more a problem than the segfault.

> We may increase the size of the guard area; but that costs memory.
> Right now, on (most) Linux systems, this guard costs 4K (one page)
> per-thread.

Could you tell me where in the code I can see this? I would love to investigate this more. Thanks!

----------------------------------------
Bug #10460: Segfault instead of stack level too deep
https://bugs.ruby-lang.org/issues/10460#change-50017

* Author: Arne Brasseur
* Status: Open
* Priority: High
* Assignee: Koichi Sasada
* Category: YARV
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-10-29 trunk 48188) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
The code to trigger this can be found here: https://gist.github.com/mbj/31163a8e712573877268

Also have a look at the comments there. A lot of different people tried it, in some cases it segfaults, in others it doesn't. It seems to have to do with version of gcc or specific CFLAGS. 

I can reproduce the problem for 2.1.3, 2.1.4, and trunk.



-- 
https://bugs.ruby-lang.org/