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

Fix pumper thread leak #4185

Merged
merged 3 commits into from
Dec 27, 2024
Merged

Fix pumper thread leak #4185

merged 3 commits into from
Dec 27, 2024

Conversation

lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented Dec 27, 2024

Fixes #4184

The basic problem is that we are spawning an PumpedProcessInput from the Mill server's redirected stdin to the stdin of any subprocess we spawn, but the PumpedProcessInput's InputPumper thread only terminates on the source stream closing, and we never close the redirected stdin of the Mill server.

Reading from the shared stdin from multiple tasks/threads concurrently doesn't really make sense, so we should probably not use PumpedProcessInput at all and just pass in a DummyInputStream with zero data. Interactive use cases like consoles and repl are handled by the os.InheritRaw codepath anyway and so won't be affected. stdout/stderr aren't affected, because having multiple tasks/threads writing lines to the same output stream is probably fine (although we could probably do a better job at ensuring it is done at a line-by-line granularity without splitting of lines between threads/tasks)

Tested manually, ran the commands in the linked issue and verified that without this PR the leaked thread can be seen in jstack, but after this PR the leaked thread is no longer present

This might also fix some of the cases where enter-on-rerun for --watch stops worked, perhaps because a leaked InputPumper is grabbing the \n character before it can be read by the Watching.scala logic

@lihaoyi lihaoyi marked this pull request as ready for review December 27, 2024 08:17
@lihaoyi lihaoyi merged commit 2ff4923 into com-lihaoyi:main Dec 27, 2024
24 of 26 checks passed
@lefou lefou added this to the 0.12.5 milestone Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test runner leaks input pumper threads
2 participants