Repository navigation
proton: Safely close DLL file in file_is_wine_builtin_dll - #10256
Open
ErenYeager1836 wants to merge 1 commit into
Open
ErenYeager1836 wants to merge 1 commit into
ErenYeager1836 wants to merge 1 commit into
Conversation
file_is_wine_builtin_dll() previously opened the target DLL via `sfile = open(path, "rb")` without closing the file handle or using a context manager, relying solely on garbage collection to release the file descriptor. Use a `with` statement so the file is closed immediately once the header tag is read.
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
Add this suggestion to a batch that can be applied as a single commit.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.Add this suggestion to a batch that can be applied as a single commit.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.Suggestion cannot be applied right now. Please check back later.
Summary
Commit bc89621 ("proton: Copy some data in appcache instead of creating symbolic link.") introduced
file_is_wine_builtin_dll(). In that function, the target DLL file was opened withsfile = open(path, "rb")without awithcontext manager or explicit close call.Because
file_is_wine_builtin_dll()is called repeatedly while scanning DLLs during prefix initialization and appcache sync, relying on garbage collection to close the file leaves open file descriptors lingering and can trigger unclosed fileResourceWarnings.This change wraps the read in a
with open(path, "rb") as sfile:context manager so the file handle is promptly closed once the 20-byte header tag has been read.Testing
python -m py_compile proton.file_is_wine_builtin_dll()behavior on Wine placeholder and native PE DLL files to ensure identical classification and prompt file descriptor cleanup.