Skip to content

Visual C++ runtime DLLs installed in the Python directory force native code to use an older runtime #154376

Description

@mfoco

Official CPython Windows packages install vcruntime140.dll and vcruntime140_1.dll in the same directory as python.exe. Windows loads these directory-local DLLs when Python starts. When native code is later loaded into the same process, Windows reuses the runtime modules already loaded from the Python directory.

Native code loaded into Python is therefore forced to use the older runtime installed in the Python directory instead of the newer Microsoft v14 runtime installed system-wide. In our case, the extension uses ctypes to load its native DLL. That DLL was built and tested with the newer runtime and crashes when the process is bound to the older copy from the Python directory.

For example, Python 3.14.6 bundles 14.42.34438.0, while the current Microsoft x64 v14 Redistributable measured on 21 July 2026 is 14.51.36247.0.

All Python 3.10–3.14 releases with official Windows x64 binaries were inspected.

Microsoft states that the installed Visual C++ runtime must be the same version as or newer than the MSVC build tools used to build the application. The current v14 Redistributable is binary compatible with applications built using the Visual Studio 2017–2026 v14 toolsets.

The older runtime DLLs installed in the Python directory defeat that compatibility model for native code loaded into the Python process because Windows reuses them instead of loading the newer system-wide runtime.

We propose to stop adding a local Visual C++ runtime to the Python installation directory. For normal installed runtimes, use the Microsoft v14 Redistributable as a centrally installed prerequisite and omit App-local vcruntime140*.dll files. The system-installed runtime is usually maintained up-to-date from Windows Update, and thus have more chances to be updated to the latest version (with latest security patches too).

As a sidenote, during this analysis we also realized that some patch version include a version of runtime that is older than those provided with the previous versions, which is another problem (e.g. 3.10.9 had VC runtime version 14.34.31931.0, while 3.10.10 and 3.10.11 had version 14.29.30139.0, and a similar issue happened more recently with version 3.11.5 and 3.11.6). This highlights the importance of this issue.

CPython versions tested on:

3.10

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowsbuildThe build process and cross-buildtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions