Closed eregon closed 3 months ago
I investigated this with @andrykonchin, it looks very similar to https://github.com/oracle/truffleruby/issues/3478#issuecomment-2015315471, except it's rb_gc_register_mark_object()
instead of rb_global_variable()
.
rb_gc_register_mark_object()
currently keeps alive the object/value, and not the ValueWrapper as it should and needed for Float & non-fixnum-long.
The JSON gem does:
void Init_parser(void)
{
...
CNaN = rb_const_get(mJSON, rb_intern("NaN"));
rb_gc_register_mark_object(CNaN);
The failing test is:
def test_load_with_options
json = '{ "foo": NaN }'
assert JSON.load(json, nil, :allow_nan => true)['foo'].nan?
end
Fixed in a88a02b56d55dd2e5dc593f6df3c24988fc8f76a
https://github.com/flori/json/actions/runs/8378309248/job/22942585131?pr=574
Reported by hsbt in https://github.com/flori/json/pull/575#issuecomment-2014156935.