Skip to content

bootloader: work around another source of VCRUNTIME140.dll leak - #8650

Merged
rokm merged 2 commits into
pyinstaller:developfrom
rokm:splash-screen-vcruntime140-leak-try2
Jul 14, 2024
Merged

rokm merged 2 commits into
pyinstaller:developfrom
rokm:splash-screen-vcruntime140-leak-try2

Conversation

@rokm

@rokm rokm commented Jul 12, 2024

Copy link
Copy Markdown
Member

Have the parent process of a splash-screen-enabled onefile application prefer the system-wide copy of VCRUNTIME140.dll (if available), by trying to preemptively load it before splash screen is set up.

Contemporary Tcl/Tk DLLs are known to depend on VCRUNTIME140.dll, so when we load them during splash screen initialization, they cause VCRUNTIME140.dll to be loaded as well. This happens after the frozen application's top-level directory is pushed into the search path; therefore, the bundled copy of the DLL is loaded, which is intended to accommodate systems that do not have system-wide copy of the DLL available.

However, the OS and/or anti-virus programs might inject additional DLLs into the process that also depend on VCRUNTIME140.dll (see the follow-up discussion under #7106); such externally loaded DLLs might prevent us from unloading the bundled copy of VCRUNTIME140.dll during the cleanup phase, and thus interfere with removal of application's temporary directory.

rokm added 2 commits July 12, 2024 11:42
At the end of `pyi_archive_open`, we go through all TOC entries to
determine whether any of them are extractable (which indicates an
application with onefile semantics). We can reuse the same scan
to check whether a SPLASH entry is present, and store the pointer
to it.

This alleviates the need for another scan in `pyi_splash_setup`,
plus it decouples the ability to check for presence of splash
screen resources from loading them. Therefore, the
`_pyi_main_setup_splash_screen` helper can now exit early if
no splash screen is available.
Have the parent process of a splash-screen-enabled onefile
application prefer the system-wide copy of `VCRUNTIME140.dll`
(if available), by trying to preemptively load it before splash
screen is set up.

Contemporary Tcl/Tk DLLs are known to depend on `VCRUNTIME140.dll`,
so when we load them during splash screen initialization, they
cause `VCRUNTIME140.dll` to be loaded as well. This happens after
the frozen application's top-level directory is pushed into the
search path; therefore, the bundled copy of the DLL is loaded, which
is intended to accommodate systems that do not have system-wide copy
of the DLL available.

However, the OS and/or anti-virus programs might inject additional
DLLs into the process that also depend on `VCRUNTIME140.dll`
(see the follow-up discussion under pyinstaller#7106); such externally loaded
DLLs might prevent us from unloading the bundled copy of
`VCRUNTIME140.dll` during the cleanup phase, and thus interfere with
removal of application's temporary directory.
@rokm

rokm commented Jul 12, 2024

Copy link
Copy Markdown
Member Author

I'm starting to wish that neither onefile mode nor splash screen existed...

@bwoodsend bwoodsend left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming we're confident enough in the assertion that bundled tcl and system VCRUNTIME140.dll are compatible...

@rokm

rokm commented Jul 12, 2024

Copy link
Copy Markdown
Member Author

Assuming we're confident enough in the assertion that bundled tcl and system VCRUNTIME140.dll are compatible...

There's always that, too...

But on the other hand, we used to fail to extract VCRUNTIME140.dll as a splash dependency in earlier PyInstaller versions (first because we did not include it in the dependency list at all, and later on because of case mismatch), and the only complains we got were from scenarios where the system did not provide its copy of the DLL.

@rokm
rokm merged commit baa12fe into pyinstaller:develop Jul 14, 2024
@rokm
rokm deleted the splash-screen-vcruntime140-leak-try2 branch July 14, 2024 09:55
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants