-
-
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
ReadFile is stream-blocking on windows #7174
Comments
that sounds about right then. perhaps we need to cache this information? although, why would windows ever make this ever a blocking call? |
I don't know, but looking at the ReactOS implementation of the same call [1] it does need to lock kernel objects and it is certainly possible that windows doesn't release some of these locks in the read request. [1] http://doxygen.reactos.org/d5/de1/iofunc_8c_a1b15fffe12d8eb6777ecfb93572051ab.html |
Looks like the problem is that this is a nonoverlapped file, hence libuv is executing a blocking ReadFile on the thread pool which holds the kernel object lock. |
Looks like a simple
in uv_get_socketname fixes this. |
ooo, nice. can you merge that locally & submit a fix upstream? this will fix one of the issues in #6795 edit: although it would be nice if this was first fixed to not cause a segfault after running a command in the REPL |
as it turns out, this it incredibly non-trivial to fix. for our usage, we can simply move jl_is_pty into libuv, and call it once at startup. however, for the general case, we need to implement full locking around the libuv ReadFile and NtQueryInformationFile calls to handle passing the file lock from our read thread to our request thread and back. |
since the microsoft bug reporter closed this issue as a design feature (in 2008), I'm bumping this out of 0.3, since the workaround (http://www.codeproject.com/Articles/18975/Listing-Used-Files :: ExtractAndInstallDrv) is completely absurd |
For future reference, and just to go ahead-full with the absurdity: (tl;dr: mintty has issues with "real" console applications) |
We seem to have had a regression with mintty here recently. Looking into it. |
following #11554, is there now a call to |
So partially undo 5863b48 in the |
or just add an explicit Base.stop_reading/Base.start_reading inside the |
I just meant a piece of it, presumably only the changes to base/REPL.jl or base/LineEdit.jl matter here. Or I could go find where |
Do you mean like diff --git a/base/Terminals.jl b/base/Terminals.jl
index a62e4b8..b1dbda0 100644
--- a/base/Terminals.jl
+++ b/base/Terminals.jl
@@ -136,18 +136,21 @@ cmove_col(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)G")
end
@windows ? begin
function raw!(t::TTYTerminal,raw::Bool)
+ stop_reading(t)
if ispty(t.in_stream)
run(if raw
`stty raw -echo onlcr -ocrnl opost`
else
`stty sane`
end,t.in_stream,t.out_stream,t.err_stream)
- true
+ ret = true
else
- ccall(:jl_tty_set_mode,
+ ret = ccall(:jl_tty_set_mode,
Int32, (Ptr{Void},Int32),
t.in_stream.handle, raw) != -1
end
+ start_reading(t)
+ return ret
end
end : begin
raw!(t::TTYTerminal, raw::Bool) = ccall(:uv_tty_set_mode, ? I tried that but it didn't seem to help. |
yeah, that's what i was thinking |
Okay bisect confirms 5863b48 is at fault, any idea for other things to try? Other portions of that commit that may need partial windows-only reversion that I may have missed? edit: |
I'm seeing the |
@vtjnash had a very good guess here: while frozen waiting for another input, |
We should probably just rewrite the relevant parts of stty ourselves then. |
tkelmen's test proves that it is the fault of julia's REPL, not stty. |
synchronization mutexes is really not fun :(. the original fix for this had a race condition if uv_read_stop was called shortly after uv_read_start or a successful read, and before the uv_pipe_zero_readfile_thread_proc thread started. There needs to be one additional check that the pipe is still active before committing to the blocking read after setting up the thread handle mutex. i believe this is fixed by JuliaLang/libuv@bd8cf2a?w=1 |
Yes, from initial testing it looks like that fixes the issue, thanks! ( |
For some reason jl_is_pty (or more precisely the pNtQueryInformationFile in uv_get socketname) blocks until another character is received on stdin.
The text was updated successfully, but these errors were encountered: