镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

proton: Safely close DLL file in file_is_wine_builtin_dll - #10256

Open
ErenYeager1836 wants to merge 1 commit into
ValveSoftware:proton_11.0from
ErenYeager1836:fix/proton-builtin-dll-fd-leak
Open

ErenYeager1836 wants to merge 1 commit into
ValveSoftware:proton_11.0from
ErenYeager1836:fix/proton-builtin-dll-fd-leak

Conversation

@ErenYeager1836

@ErenYeager1836 ErenYeager1836 commented Oct 14, 2026 •

Copy link
Copy Markdown

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 with sfile = open(path, "rb") without a with context 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 file ResourceWarnings.

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

  • Verified syntax with python -m py_compile proton.
  • Tested file_is_wine_builtin_dll() behavior on Wine placeholder and native PE DLL files to ensure identical classification and prompt file descriptor cleanup.

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.
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.

1 participant