-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DIGITS buffer may be reused while in-use #29885
Comments
Are you using the Juno REPL? I vaguely recall that Juno sometimes |
yes, I have JuliaPro with the default Atom/Juno editor. |
Please report to https://github.com/JunoLab/Juno.jl (unless you can reproduce this in the normal REPL). |
Yeah, I can (kind of) repro this. It's a super weird bug which might even be caused by Base, but not sure. With JunoLab/Atom.jl@4598ce3 I can't repro this anymore, so fingers crossed. |
There's a race condition in the design of the Grisu output: we re-use the same buffer (DIGITS), even though that buffer might already be in use (missing a lock). We can simulate this failure pretty easily: julia> p = Pipe()
Pipe(RawFD(0xffffffff) init => RawFD(0xffffffff) init, 0 bytes waiting)
julia> Base.link_pipe!(p, reader_supports_async=true, writer_supports_async=true)
Pipe(RawFD(0x00000013) open => RawFD(0x00000011) open, 0 bytes waiting)
julia> t1 = @async write(p, zeros(UInt8, 2^18))
Task (runnable) @0x00007f54b1e08eb0
julia> t1
Task (runnable) @0x00007f54b1e08eb0
julia> t2 = @async (print(p, 12.345); close(p.in))
Task (runnable) @0x00007f54b2c17820
julia> t2
Task (runnable) @0x00007f54b2c17820
julia> 9.8
9.8
julia> read(p, 2^18);
julia> read(p, String)
"98.345" |
Is there some way to work around this on our side? Just wrapping some random code in an |
we should just make the DIGITS buffer task local |
In places where you control the output, you can add an explicit call to |
Indeed Juno developers said there was an issue with syncing of the Workspace Pane, see |
The underlying issue is still in Base, and the workaround in that commit seems to make the race condition less likely to trigger. So this issue definitely isn't fixed for good on the Juno side. |
It will be an issue for multithreaded I/O, however, which is coming soon. |
Threads won't make much difference here since the buffers are already thread-local. |
Here is a minimal example (using the foo function as defined in https://docs.julialang.org/en/v1/manual/functions/index.html). REPL gives a wrong result almost every time I run it (sometimes the first, sometimes the second return value is wrong there)! I don't think that it is an issue with a particular function, as I had observed the same behaviour with another function as well. For functions with a single output/return it seems to consistently give a correct result.
The correct return should be (4.4, 4.59).
The text was updated successfully, but these errors were encountered: