Repository navigation
Don't block the tracked program on stderr in run --live - #1102
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1102 +/- ##
==========================================
- Coverage 92.38% 92.37% -0.02%
==========================================
Files 103 103
Lines 13506 13532 +26
Branches 483 484 +1
==========================================
+ Hits 12478 12500 +22
- Misses 1028 1032 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
42e77a2 to
5705347
Compare
The child process started by `memray run --live` wrote its stderr into a pipe that nobody read until the TUI exited. If the program wrote enough to fill the pipe buffer (about 64 KiB on Linux), it blocked in `write()` and stopped making progress. Send its stderr to a temporary file instead, and read that back when the child fails, so the error output is still shown. Signed-off-by: Patrick Hintermayer <patrick@immometrica.com>
5705347 to
3beac65
Compare
godlygeek
left a comment
There was a problem hiding this comment.
LGTM, thanks for the contribution @patrick-immometrica!
I switched the test up to use a FIFO opened and written to by the child process but never closed, so that we can detect the child having already died based on getting an EOF on that FIFO. As the test was originally written, we might send the q while the program was still running, or we might send it after the program had exited. Now we are guaranteed to only send it once the program has exited.
memray run --livestarted the tracked program withstderr=subprocess.PIPE, and nothing read the pipe until the TUI exited. A program that writes more than the pipe buffer (64 KiB on Linux) to stderr blocks inwrite()and stops running, while the TUI keeps showing the frozen heap.The child's stderr now goes to a
tempfile.TemporaryFile(), which is read back and printed when the child exits with an error, the same as before.The new integration test runs a script that writes about 250 KB to stderr, touches a marker file and exits with 1. It checks that the marker was created and that the last line shows up in memray's stderr. Without the fix, the marker never shows up. The two unit tests that checked
stderr=-1in thePopencall now accept any value there.Closes: #1098