Skip to content

dtoa is not ractor safe #527

@tompng

Description

@tompng

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));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions