Thanks for reporting the bug. I reproduced the problem on Fedora 26 x86-64, fixed it in master by applying the attached patch, and am boldly marking the bug as fixed. As Eli and Daniel mentioned, this area of Emacs cannot be 100% reliable and to some extent is indeed a "ticking time bomb". That being said, the problem in this particular case was that Emacs had a bad heuristic for guessing whether a segmentation violation address was due to stack overflow on GNU/Linux. This bad heuristic has been in place for years without anybody reporting it. It's good that we fixed this bug (though I hope "normal" users never notice the bug fix :-).