{{ message }}
gh-120754: Ensure _stat_atopen is cleared on fd change#125166
Merged
vstinner merged 11 commits intoNov 1, 2024
Merged
Conversation
Performed an audit of `fileio.c` and `_pyio` and made sure anytime the fd changes the stat result, if set, is also cleared/changed. There's one case where it's not cleared, if code would clear it in __init__, keep the memory allocated and just do another fstat with the existing memory.
vstinner
reviewed
Oct 9, 2024
cmaloney
commented
Oct 9, 2024
vstinner
reviewed
Oct 9, 2024
vstinner
left a comment
Member
There was a problem hiding this comment.
There are compiler warnings that you can see in the review tab.
Sorry, something went wrong.
Contributor
Author
|
I think the latest commit fixes the compiler warnings (was a testing/debugging assert I accidentally committed with a missing |
Sorry, something went wrong.
vstinner
reviewed
Oct 10, 2024
Contributor
Author
|
CI "Tests / Ubuntu SSL tests with OpenSSL" failed because of what looks like a network hang / not these changes: |
Sorry, something went wrong.
vstinner
reviewed
Oct 30, 2024
Member
|
Merged, thank you. |
Sorry, something went wrong.
picnixz
pushed a commit
to picnixz/cpython
that referenced
this pull request
Dec 8, 2024
…n#125166) Performed an audit of `fileio.c` and `_pyio` and made sure anytime the fd changes the stat result, if set, is also cleared/changed. There's one case where it's not cleared, if code would clear it in __init__, keep the memory allocated and just do another fstat with the existing memory.
ebonnal
pushed a commit
to ebonnal/cpython
that referenced
this pull request
Jan 12, 2025
…n#125166) Performed an audit of `fileio.c` and `_pyio` and made sure anytime the fd changes the stat result, if set, is also cleared/changed. There's one case where it's not cleared, if code would clear it in __init__, keep the memory allocated and just do another fstat with the existing memory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.
While adding _stat_atopen I accidentally created a leak in the C implementation because the
_stat_atopenmember was set to NULL in the C implementation, but the memory wasn't freed. That was resolved, but it showed there were a number of potential cases where_stat_atopenshould be cleared (the information is out of date because the fd changed) that it was not. In this PR I audited by reading through FileIO (in _io and _pyio), and in all cases where the fd is changed/closed made sure to clear/reset _stat_atopen as well.Followup from: #124225 (comment), cc: @vstinner