From: "mame (Yusuke Endoh) via ruby-core" Date: 2023-10-13T03:18:33+00:00 Subject: [ruby-core:115030] [Ruby master Bug#18903] Stack overflow signal handling seems to be triggered once and then not working after Issue #18903 has been updated by mame (Yusuke Endoh). Discussed at the dev meeting. @nobu said he would investigate if he could fix it with M2. Recovering from a stack overflow in C is not portable and complete, but it is a fact that they work almost well in Linux, which is the main production environment. If we make it a fatal error that cannot be rescued normally, it might impact on users of Rails apps, job queues like Sidekiq, etc. ---------------------------------------- Bug #18903: Stack overflow signal handling seems to be triggered once and then not working after https://bugs.ruby-lang.org/issues/18903#change-104901 * Author: chrisseaton (Chris Seaton) * Status: Open * Priority: Normal * ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- This program creates a recursive object graph and then tries to convert it to JSON with no max depth, so it stack overflows in C code that does no co-operative stack overflow checks, as the bytecode interpreter would. This therefore triggers a segmentation fault and the stack overflow detection there. It works the first time, but the second time around it doesn't and the program hard crashes on M1. Is there something like a guard page permission that is switched during the handling, and needs to switched back for the guard page to work again? Note that it isn't JSON specific - I think any stack overflow within C code would do it. ```ruby require 'json' a = [] a << a begin JSON.dump(a) rescue Exception puts 'rescued' end JSON.dump(a) ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/