FIX intermittent Windows module enumeration failure (#217)#219
Open
ogrisel wants to merge 16 commits into
Open
FIX intermittent Windows module enumeration failure (#217)#219ogrisel wants to merge 16 commits into
ogrisel wants to merge 16 commits into
Conversation
Use CreateToolhelp32Snapshot for atomic module discovery on Windows, with GetModuleFileNameExW for long paths and graceful per-module fallbacks when handles go stale. Add Windows integration tests for paths longer than MAX_PATH. Co-authored-by: Cursor <cursoragent@cursor.com>
ogrisel
commented
Jul 9, 2026
- Run repeated-init stress test on all platforms - Drop redundant OpenBLAS glob pattern and win32 guard in utils - Remove MAX_PATH tests from SAFE_SKIPPED_TESTS whitelist Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Dugal Harris <dugal@leftfield.online> Co-authored-by: Cursor <cursoragent@cursor.com>
Correct numpy.libs glob to use the site-packages sibling directory, add conda-forge Library/bin patterns, and fall back to the loaded OpenBLAS filepath from ThreadpoolController when globs find nothing. Co-authored-by: Cursor <cursoragent@cursor.com>
Use extended-length paths when copying and loading test DLLs so LoadLibrary works beyond MAX_PATH, and pass the module buffer directly to EnumProcessModulesEx to match its ctypes signature. Co-authored-by: Cursor <cursoragent@cursor.com>
Use libopenblas-prefixed destination DLL names so conda builds are recognized, normalize extended-length paths for comparisons, prefer shipped libscipy_openblas sources, and detect truncation when the resolved path fills the GetModuleFileNameExW buffer. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
ogrisel
commented
Jul 9, 2026
dugalh
reviewed
Jul 9, 2026
Load cv2 before stressing ThreadpoolController() to match the Windows conda-forge repro from issue joblib#217, and install OpenCV in CI jobs that exercise this test. Co-authored-by: Cursor <cursoragent@cursor.com>
Use GetCurrentProcess(), trust snapshot szExePath on the happy path, and resolve fallback module paths with GetModuleFileNameW before the slower GetModuleFileNameExW long-path lookup. Co-authored-by: Cursor <cursoragent@cursor.com>
ogrisel
commented
Jul 10, 2026
ogrisel
left a comment
Contributor
Author
There was a problem hiding this comment.
Code style review.
Move ThreadpoolController usage to module scope in utils, hoist conda OpenBLAS globs out of the numpy import block, and inline Windows MAX_PATH test setup in the tests instead of small utils helpers. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
ogrisel
commented
Jul 10, 2026
ogrisel
left a comment
Contributor
Author
There was a problem hiding this comment.
I think this LGTM. The licensing issue is still there but will be addressed in a follow-up PR to decouple the concerns.
cc @jeremiedbb @tomMoral.
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
OSError("GetModuleFileNameEx failed")on Windows when DLLs are loaded or unloaded during library discovery (reported with conda-forge OpenCV).EnumProcessModulesEx+GetModuleFileNameExWscan with a snapshot-first approach usingCreateToolhelp32Snapshot, keeping long-path support viaGetModuleFileNameExWand graceful per-module fallbacks.MAX_PATH, inspired by the local repro documented in ENH Support path length > MAX_PATH=260 on Windows #189 (comment).Closes #217
Test plan
py311_conda_forge_openblas): new teststest_windows_library_path_longer_than_max_pathandtest_windows_library_path_exceeds_internal_limitpassAI assistance disclosure
This pull request was prepared with assistance from an AI coding agent (Cursor / Claude).
Made with Cursor