-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Make regrtest with --huntrleaks check for fd leaks #62374
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
Comments
regrtest already tests for refcount leaks and memory allocation leaks. It can also be made to check for file descriptor leaks (and perhaps also handles on Windows). Running with the attached patch makes it look like test_openpty, test_shutil, test_subprocess, test_uuid all leak fds on Linux, but I have not investigated: $ ./python -m test.regrtest -R 3:3 test_openpty test_shutil test_subprocess test_uuid
[1/4] test_openpty
123456
......
test_openpty leaked [2, 2, 2] fds, sum=6
[2/4/1] test_shutil
beginning 6 repetitions
123456
......
test_shutil leaked [4, 4, 4] fds, sum=12
[3/4/2] test_subprocess
beginning 6 repetitions
123456
......
test_subprocess leaked [5, 5, 5] fds, sum=15
[4/4/3] test_uuid
beginning 6 repetitions
123456
......
test_uuid leaked [1, 1, 1] fds, sum=3
4 tests failed:
test_openpty test_shutil test_subprocess test_uuid |
New changeset a7381fe515e8 by Richard Oudkerk in branch '2.7': New changeset 46fe1bb0723c by Richard Oudkerk in branch '3.3': |
The test_shutil leak is caused by bpo-17899. The others are fixed by a7381fe515e8 and 46fe1bb0723c. |
Updated version which adds checks for handle leaks on Windows. |
Just flagging this up as testing is rather important. |
The patch looks good. |
Why not using os.fstat() instead of os.dup() to check if a file descriptor is open or not? It's strange to create a new file descriptor with os.dup() to count the file descriptors. |
I asked myself the same question, but IIRC, fstat() doesn't always |
Can you please elaborate? |
Not really, since I don't know much about Windows, but that's |
I can't remember why I did not use fstat() -- probably it did not occur to me. |
Modified patch to use os.fstat(), and try to use /proc/self/fd/ on Linux. |
New changeset 379aad232000 by Victor Stinner in branch '3.4': New changeset 0ced2d2325fb by Victor Stinner in branch 'default': |
New changeset 746339776f19 by Victor Stinner in branch '3.4': New changeset 017d701116d5 by Victor Stinner in branch 'default': |
I probably have Alzeihmer, I was sure I heard a reasonable case for In any case, I too prefer fstat(), since it doesn't require creating a The only comment I have about this patch is I think that the helper |
fstat() can do I/O, or can fail for other reasons. If you don't want to create a new fd, I think you can do dup2(fd, fd). I don't understand the reason for the following code: + def check_handle_deltas(deltas): Can you add a comment? |
Oh, I forgot this reason. Maybe we should add a comment to explain that. I mean in the patch for this issue but also in is_valid_fd() (Python/pythonrun.c). |
New changeset 0e7d71a3bf0d by Victor Stinner in branch 'default': |
New changeset 72129c767c92 by Victor Stinner in branch 'default': |
I commited the first part to check for file descriptor leak. I didn't commit the second part, to check for Windows handle leak. |
New changeset ec2ef7525fa5 by Victor Stinner in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: