Provide better error info on dll mismatch - #38
Merged
birkholz-cubert merged 5 commits intoAug 19, 2026
Conversation
The extension and the cuvis library are in sync when built, but the library installed on a user's machine can be older and simply not export functions the extension imports. That made `import cuvis_il` fail with an opaque loader error and took down every consumer, including ones that never needed the missing part. The module is now delay-loaded on Windows and lazily bound on Linux, so the load survives. At import the loader reads which cuvis functions the built module needs out of its own PE import table or ELF .dynsym, probes each against the library it loaded, and replaces whatever is absent with a stub that raises RuntimeError naming the symbol. `cuvis_il.missing_symbols` reports them, so a consumer can decide which of its features are affected, and `built_against_version` says which SDK the binding expects. No list of function names is maintained anywhere; the needed set comes from the binary. Verified on Linux by building against the 3.5.3 SDK image and running against 3.4.1, which correctly reported the three dead-pixel-correction functions added since.
The version the binding was compiled against was published through the Python C API, so it existed only for the Python target and needed a not-CSharp guard. It is now an ordinary wrapped function, cuvis_built_against_version(), which every SWIG target language gets for free; verified by building the C# binding from the same interface. The macro is named CUVIS_BINDING_BUILT_VERSION accordingly. The delay-load guard now distinguishes a library that cannot be loaded at all (missing, or its own dependencies such as the CUDA runtime cannot be found) from one that loads but lacks the function, which previously shared one message. cuvis_il.library_path names the library the probe actually opened, so a consumer can report which file it is talking about.
birkholz-cubert
deleted the
feature/provide_better_error_info_on_dll_mismatch
branch
August 19, 2026 13:01
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.
Makes an outdated or mismatched cuvis library visible instead of fatal. Needs cuvis.swig#14 (merged), hence the submodule bump.
RuntimeErrornaming it, rather than aborting the process.cuvis_il.missing_symbolsnames them all.$CUVISbefore anything binds, so the Windows delay-load helper cannot pick up a stray cuvis.dll from the current directory.cuvis_il/_imports.py), leaving__init__.pya readable top-to-bottom narrative.Verified
cuvis_acq_cont_dead_pixel_correction_*functions reported, shadowed, and raising.cuvis_ilwheel, an extension compiled without the define, and a library banner with no build hash all report "unknown" rather than failing.cuvis.pythonsuite: 90 passed on both platforms.Known gap
LD_BIND_NOW=1(or musl) defeats lazy binding and restores the oldImportError: undefined symbol.