Project

General

Profile

Actions

Bug #18903

open

Stack overflow signal handling seems to be triggered once and then not working after

Added by chrisseaton (Chris Seaton) over 2 years ago. Updated about 1 year ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
[ruby-core:109163]

Description

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.

require 'json'

a = []
a << a

begin
  JSON.dump(a)
rescue Exception
  puts 'rescued'
end

JSON.dump(a)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0