-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
The various calls to grisu() are not thread-safe, due to the use of the module-level DIGITS buffer:
function grisu(v::AbstractFloat, mode, requested_digits)
return tuple(Base.Grisu.grisu(v, mode, requested_digits)..., Base.Grisu.DIGITS)
end
Different threads may write to this buffer before it is read by the calling function, causing corrupted output. In my particular case, this was corrupting the axis labels on plots generated in a parallel for loop.
This can be fixed by defining the function as:
function grisu(v::AbstractFloat, mode, requested_digits)
return tuple(Base.Grisu.grisu(v, mode, requested_digits)..., Base.Grisu.DIGITSs[Threads.threadid()])
end
Metadata
Metadata
Assignees
Labels
No labels