Skip to content

filedescriptor leaks in subprocesses? #586

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

Open
radoering opened this issue Apr 16, 2025 · 4 comments · May be fixed by #594
Open

filedescriptor leaks in subprocesses? #586

radoering opened this issue Apr 16, 2025 · 4 comments · May be fixed by #594
Labels
bug Something isn't working

Comments

@radoering
Copy link

We noticed that some tests of Python's test suite related to file descriptors in subprocesses started failing with python-build-standalone 3.12.8.

The following tests pass with 3.12.7 but fail with 3.12.8 (and still fail with 3.12.10) - tested on Ubuntu 20.04 and 24.04:

python -m test -v -m test_pass_fds_redirected test_subprocess.py
python -m test -v -m test_no_* test_cmd_line.py
python -m test -v -m test_close_file test_posix.py

(The tests succeed with a deadsnakes Python 3.12.10.)

All tests have in common that they start a subprocess and check that some file descriptors, which are open in the main process, are closed in the subprocess - and fail because they are not.

Does anyone have an idea why this could be an issue in python-build-standalone now, why it was not an issue before and if/how it could be fixed?

@zanieb
Copy link
Member

zanieb commented Apr 16, 2025

Thanks for the report! Unfortunately, I have no clue why this would be off the top of my head.

@zanieb zanieb added the bug Something isn't working label Apr 16, 2025
@radoering
Copy link
Author

I narrowed it down a bit further:

The issue has been introduced in 20250106. (The tests pass with 3.12.8 from 20241219.)

Further, the issue exists only for 3.12 and 3.13. It does not exist for 3.11.

@radoering
Copy link
Author

I narrowed it down even further:

The issue has been introduced in 0be0a57 and in particular by applying the BOLT flag -hugify. By removing this part of the patch, I was able to built a Python that passes the mentioned tests.

@zanieb If you like, I can create a PR removing this part of the patch. If you prefer to carry out further investigations before, that is also fine with me. (We are building on our own with some modifications anyway.)

@zanieb
Copy link
Member

zanieb commented Apr 21, 2025

Interesting, thanks for digging into it! I really appreciate it.

I'm happy to revert that change, if you want to put up a pull request. We'll want to coordinate with the BOLT and CPython teams afterwards to figure out why there's a regression, I can follow up on that.

radoering added a commit to radoering/python-build-standalone that referenced this issue Apr 21, 2025
With `-hugify` the following tests fail:

python -m test -v -m test_pass_fds_redirected test_subprocess.py
python -m test -v -m test_no_* test_cmd_line.py
python -m test -v -m test_close_file test_posix.py

See astral-sh#586 for details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants