Skip to content
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

Deadlock in reading stdout from cmd #22832

Closed
visr opened this issue Jul 16, 2017 · 0 comments · Fixed by #22886
Closed

Deadlock in reading stdout from cmd #22832

visr opened this issue Jul 16, 2017 · 0 comments · Fixed by #22886
Labels
bug Indicates an unexpected problem or unintended behavior io Involving the I/O subsystem: libuv, read, write, etc.

Comments

@visr
Copy link
Contributor

visr commented Jul 16, 2017

I want to read the stdout from an external program and process the results in Julia. However it sometimes hangs indefinitely.

It was previously discussed on Discourse, but @vtjnash suggested to make an issue here, he could reproduce it by running this on all cores (I also see it on one core):

while true
    readstring(`dd if=/dev/zero bs=1048576 count=2`)
end

It just reads in two MiB of zeroes, in two blocks.
Successful iterations of the loop will print this to stderr:

2+0 records in
2+0 records out
2097152 bytes (2,1 MB, 2,0 MiB) copied, 0,00447523 s, 469 MB/s

Until it hangs. Killing it with Ctrl-C then gives the following:

1+0 records in
0+0 records out
0 bytes copied, 11,1429 s, 0,0 kB/s

signal (2): Interrupt
while loading /home/martijn/test/dd.jl, in expression starting on line 1
unknown function (ip: 0x7fb138855498)
uv__epoll_wait at /home/martijn/src/julia/deps/srccache/libuv-52d72a52cc7ccd570929990f010ed16e2ec604c8/src/unix/linux-syscalls.c:321
uv__io_poll at /home/martijn/src/julia/deps/srccache/libuv-52d72a52cc7ccd570929990f010ed16e2ec604c8/src/unix/linux-core.c:267
uv_run at /home/martijn/src/julia/deps/srccache/libuv-52d72a52cc7ccd570929990f010ed16e2ec604c8/src/unix/core.c:354
process_events at ./libuv.jl:82 [inlined]
wait at ./event.jl:216
wait at ./event.jl:27
jl_call_fptr_internal at /home/martijn/src/julia/src/julia_internal.h:369 [inlined]
jl_call_method_internal at /home/martijn/src/julia/src/julia_internal.h:388 [inlined]
jl_apply_generic at /home/martijn/src/julia/src/gf.c:1929
jl_apply_2va at /home/martijn/src/julia/src/rtutils.c:287
stream_wait at ./stream.jl:42
close at ./stream.jl:326
open at ./process.jl:588
read at ./process.jl:645
readstring at ./process.jl:651
macro expansion at /home/martijn/test/dd.jl:2 [inlined]
anonymous at ./<missing> (unknown line)
jl_call_fptr_internal at /home/martijn/src/julia/src/julia_internal.h:369 [inlined]
jl_call_method_internal at /home/martijn/src/julia/src/julia_internal.h:388 [inlined]
jl_toplevel_eval_flex at /home/martijn/src/julia/src/toplevel.c:594
jl_parse_eval_all at /home/martijn/src/julia/src/ast.c:909
jl_load at /home/martijn/src/julia/src/toplevel.c:620
include_from_node1 at ./loading.jl:556
jl_call_fptr_internal at /home/martijn/src/julia/src/julia_internal.h:369 [inlined]
jl_call_method_internal at /home/martijn/src/julia/src/julia_internal.h:388 [inlined]
jl_apply_generic at /home/martijn/src/julia/src/gf.c:1929
include at ./sysimg.jl:14
jl_call_fptr_internal at /home/martijn/src/julia/src/julia_internal.h:369 [inlined]
jl_call_method_internal at /home/martijn/src/julia/src/julia_internal.h:388 [inlined]
jl_apply_generic at /home/martijn/src/julia/src/gf.c:1929
process_options at ./client.jl:315
_start at ./client.jl:383
jl_call_fptr_internal at /home/martijn/src/julia/src/julia_internal.h:369 [inlined]
jl_call_method_internal at /home/martijn/src/julia/src/julia_internal.h:388 [inlined]
jl_apply_generic at /home/martijn/src/julia/src/gf.c:1929
unknown function (ip: 0x401e40)
unknown function (ip: 0x401602)
__libc_start_main at /build/glibc-bfm8X4/glibc-2.23/csu/../csu/libc-start.c:291
unknown function (ip: 0x4016b8)
unknown function (ip: 0xffffffffffffffff)
Allocations: 210788 (Pool: 210123; Big: 665); GC: 35

As noted on Discourse, when using smaller block sizes, it always seems to hang after 65536 (2^16) bytes. This is seen on julia 0.5/0.6/master and all OS, though on Unix it seems to happen more quickly than Windows.

@vtjnash said that it seems like something is dropping an event notification.

cc @evetion

@StefanKarpinski StefanKarpinski added bug Indicates an unexpected problem or unintended behavior io Involving the I/O subsystem: libuv, read, write, etc. labels Jul 16, 2017
vtjnash added a commit that referenced this issue Jul 20, 2017
when calling uv_shutdown on a handle being written to by another process
we might never get the UV__POLLOUT notification
but we also don't need to delay the uv_close call
if we have nothing to write

in the future, we should introduce a new `uv_drain` callback,
instead of continuing to abuse uv_shutdown for this purpose

fix #22832
vtjnash added a commit that referenced this issue Jul 20, 2017
when calling uv_shutdown on a handle being written to by another process
we might never get the UV__POLLOUT notification
but we also don't need to delay the uv_close call
if we have nothing to write

in the future, we should introduce a new `uv_drain` callback,
instead of continuing to abuse uv_shutdown for this purpose

fix #22832
vtjnash added a commit that referenced this issue Jul 20, 2017
when calling uv_shutdown on a handle being written to by another process
we might never get the UV__POLLOUT notification
but we also don't need to delay the uv_close call
if we have nothing to write

in the future, we should introduce a new `uv_drain` callback,
instead of continuing to abuse uv_shutdown for this purpose

fix #22832
vtjnash added a commit that referenced this issue Jul 21, 2017
when calling uv_shutdown on a handle being written to by another process
we might never get the UV__POLLOUT notification
but we also don't need to delay the uv_close call
if we have nothing to write

in the future, we should introduce a new `uv_drain` callback,
instead of continuing to abuse uv_shutdown for this purpose

fix #22832
visr added a commit to visr/LasIO.jl that referenced this issue Jul 26, 2017
…n't dead lock. Ugly workaround."

This reverts commit 2a5c158.

Issue
JuliaLang/julia#22832
is fixed with
JuliaLang/julia#22886
vtjnash added a commit that referenced this issue Jul 28, 2017
fix an IO deadlock condition (#22832)

disabled test seems to indicate this doesn't fix it fully, but it seems that only reproduces on CI, not on any of my local machines
visr added a commit to visr/LasIO.jl that referenced this issue Aug 2, 2017
…n't dead lock. Ugly workaround."

This reverts commit 2a5c158.

Issue
JuliaLang/julia#22832
is fixed with
JuliaLang/julia#22886
visr added a commit to visr/LasIO.jl that referenced this issue Aug 17, 2017
…n't dead lock. Ugly workaround."

This reverts commit 2a5c158.

Issue
JuliaLang/julia#22832
is fixed with
JuliaLang/julia#22886
ararslan pushed a commit that referenced this issue Sep 11, 2017
fix an IO deadlock condition (#22832)

disabled test seems to indicate this doesn't fix it fully, but it seems that only reproduces on CI, not on any of my local machines

Ref #22886
(cherry picked from commit 930a5f0)
visr pushed a commit to visr/julia that referenced this issue Sep 15, 2017
when calling uv_shutdown on a handle being written to by another process
we might never get the UV__POLLOUT notification
but we also don't need to delay the uv_close call
if we have nothing to write

in the future, we should introduce a new `uv_drain` callback,
instead of continuing to abuse uv_shutdown for this purpose

fix JuliaLang#22832
visr added a commit to visr/julia that referenced this issue Sep 15, 2017
visr pushed a commit to visr/julia that referenced this issue Sep 15, 2017
when calling uv_shutdown on a handle being written to by another process
we might never get the UV__POLLOUT notification
but we also don't need to delay the uv_close call
if we have nothing to write

in the future, we should introduce a new `uv_drain` callback,
instead of continuing to abuse uv_shutdown for this purpose

fix JuliaLang#22832
vtjnash added a commit to vtjnash/julia that referenced this issue Jun 8, 2018
let's hope it passes and doesn't just hang...
vtjnash added a commit that referenced this issue Jun 8, 2018
let's hope it passes and doesn't just hang...
vtjnash added a commit that referenced this issue Jun 8, 2018
let's hope it passes and doesn't just hang...
vtjnash added a commit that referenced this issue Jun 8, 2018
let's hope it passes and doesn't just hang...
vtjnash added a commit that referenced this issue Jun 19, 2018
let's hope it passes and doesn't just hang...
vtjnash added a commit that referenced this issue Jun 25, 2018
let's hope it passes and doesn't just hang...
vtjnash added a commit that referenced this issue Jun 25, 2018
let's hope it passes and doesn't just hang...
@evetion evetion mentioned this issue Jun 29, 2018
3 tasks
ararslan pushed a commit that referenced this issue Jul 2, 2018
when calling uv_shutdown on a handle being written to by another process
we might never get the UV__POLLOUT notification
but we also don't need to delay the uv_close call
if we have nothing to write

in the future, we should introduce a new `uv_drain` callback,
instead of continuing to abuse uv_shutdown for this purpose

fix #22832

Ref #22886
(cherry picked from commit 8949a95)
ararslan pushed a commit that referenced this issue Jul 2, 2018
let's hope it passes and doesn't just hang...

(cherry picked from commit 04456b9)
jrevels pushed a commit that referenced this issue Jul 2, 2018
let's hope it passes and doesn't just hang...
vtjnash added a commit that referenced this issue Feb 5, 2021
vtjnash added a commit that referenced this issue Apr 2, 2021
vtjnash added a commit that referenced this issue Jun 2, 2021
shirodkara pushed a commit to shirodkara/julia that referenced this issue Jun 9, 2021
johanmon pushed a commit to johanmon/julia that referenced this issue Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior io Involving the I/O subsystem: libuv, read, write, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants