-
Notifications
You must be signed in to change notification settings - Fork 24
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
Wurlitzer hangs process when pipe/buffer is full #15
Comments
Thanks for the test! I think the OS controls the buffer size for pipes, so we don't have much of an option there. My first guess for the test to pass was to switch I ran the test again and it still hung. It turns out it's hanging in the call to |
Thanks for the quick reply! When I removed the fflush calls completely it hanged on |
EDIT: Manage to dig a little bit deeper. When I dump the stack trace of all threads it's clear that the process is blocked on
From my understanding
|
Interesting. The test passed for me, but when I run it more times, I can see that I didn't. The hang does seem to always be in fflush for me, though, not select. I think I can see that there's a race condition there now - if the too-large send happens in between select and fflush, the fflush will block forever. In general, now that I know fflush blocks when the buffer is full, I think that calling fflush from the same thread that's reading from the pipe is a fundamentally unsafe pattern. My first idea for this is spawning yet another thread that does nothing but call flush. That seems a little wasteful, but I don't see another way to solve the dueling problems of:
|
I haven't seen problem 1 happening before so I don't have much to contribute to the discussion. Have you considered using a file instead of a pipe? |
Hi,
We're using Wurlitzer at Comet.ml and we found that when the C library prints a large string
the entire process hangs. We manage to create a test that reproduces this. Would it be possible to increase the buffer size or find a workaround?
The text was updated successfully, but these errors were encountered: