This code crashes.
4.times.map do
Ractor.new do
loop { raise unless BigDecimal(3.14) }
end
end
sleep 1
GC.start
exit
Simplifying rb_float_convert_to_BigDecimal to always return BigDecimal(1), I discovered that BigDecimal_dtoa is suspicious.
The above ruby code only crash if the dtoa part is uncommented in the code below.
static VALUE
rb_float_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception)
{
// int decpt, negative_p;
// char *e;
// char *p = BigDecimal_dtoa(3.14, 0, 0, &decpt, &negative_p, &e);
// xfree(p);
return rb_inum_convert_to_BigDecimal(INT2FIX(1));
}
This code crashes.
Simplifying
rb_float_convert_to_BigDecimalto always returnBigDecimal(1), I discovered thatBigDecimal_dtoais suspicious.The above ruby code only crash if the
dtoapart is uncommented in the code below.