Repository navigation
image: find ImageMagick's coders beside a build tree on Windows; test with no MAGICK_* set - #774
Merged
Merged
Conversation
… it with no MAGICK_* set The cvcpkg ImageMagick is extracted, not installed, so on Windows libcvc points MAGICK_CODER_MODULE_PATH / MAGICK_FILTER_MODULE_PATH / MAGICK_CONFIGURE_PATH at the bundle before it initializes Magick. Setting them from inside the process works. MagickCore 7.1.2 reads them with GetEnvironmentVariableW each time it opens a module, _putenv_s writes the OS environment block as well as the CRT's copy, and the bundle's MagickCore has no DllMain genesis that could run first. The ImageTest/CvcCliTest failures seen without the variables came from Magick being reached without the bootstrap, which #673 fixed. What remained: - The layout guess was dllDir\..\..\..\..\deps\bin, which matches no common layout. Try <ancestor>\deps\bin for the first four ancestors of cvc.dll's directory instead, so <root>\build-X\bin (or bin\Release) next to <root>\deps is found. A build tree whose loaded ImageMagick DLL has no coders beside it (CORE_RL_*.dll next to the exe) failed ImageTest.ReadsCmykInputAsRgb and CvcCliTest.Vol2ImgExportsSlices / Img2VolImportsSlices unless CVC_DEPS_PREFIX was set. - A deps prefix the environment names now comes before that guess. - When no directory has coders, nothing is set. Before, the variables were pointed at cvc.dll's directory, which also hid the registry paths of an ImageMagick that is installed. - MAGICK_CONFIGURE_PATH is set only to a share\imagemagick that holds the config, now also found for a <prefix>\debug\bin. - A variable counts as already set by the OS environment block, the one MagickCore reads, not the CRT's copy. magick_bootstrap_test is a new executable. It removes the MAGICK_* variables during static initialization, before anything initializes Magick, then checks that cvc::init_imagemagick() alone finds the coders and config, and decodes xc:, PNG and JPEG through Magick++ and TIFF through cvc::image. CI sets the variables for the whole Windows ctest step, so until now no test exercised the lookup there.
transfix
added a commit
that referenced
this pull request
Oct 26, 2026
The package-windows test step pointed MAGICK_CODER_MODULE_PATH, MAGICK_FILTER_MODULE_PATH and MAGICK_CONFIGURE_PATH at the deps prefix for every test. Since #673 and #774 libcvc finds the extracted cvcpkg ImageMagick's coders and config itself, so the variables only hid that lookup from every test but magick_bootstrap_test. Without them the whole suite, ImageTest and the CvcCliTest vol2img/img2vol cases included, runs as a local build does. The recipe/windows-2022 job never set them: on #774 it passed all 4389 tests, ImageTest.* and MagickBootstrapTest.* among them. The removed block's debug\bin branch was dead, since the Windows matrix is Release only.
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.
On Windows the cvcpkg ImageMagick is extracted, not installed, so it has no registry entry. libcvc points
MAGICK_CODER_MODULE_PATH/MAGICK_FILTER_MODULE_PATH/MAGICK_CONFIGURE_PATHat the bundle before it initializes Magick (set_magick_paths_win()insrc/cvc/image/magick_io.cpp). This PR fixes the layout lookup that remained broken and adds a test that runs with none of those variables set.What was actually wrong
Three suspects were open: a different CRT inside ImageMagick, the bootstrap running after genesis had cached the path, and the bootstrap never being reached. A standalone exe linked against the same
depsImageMagick (7.1.2) ruled out the first two:GetEnvironmentVariableWand no CRTgetenv, so it reads the OS environment block._putenv_swrites that block as well as the CRT's copy. The exe saw the variables, and Magick decodedxc:and PNG after an in-process_putenv_s.xc:lookup fixes the next lookup.IsMagickCoreInstantiated()is false atmain, so the bundle has no DllMain genesis that could run before libcvc.The failures seen on 2026-10-09 came from the third suspect: Magick was reached without the bootstrap. #673 has since fixed that, and it also tries the directory of the loaded
CORE_RL_MagickCore_.dll. What remained:dllDir\..\..\..\..\deps\binmatches no common layout. This PR tries<ancestor>\deps\binfor the first four ancestors of cvc.dll's directory instead, which finds<root>\depsnext to<root>\build-X\bin(orbin\Release). A deps prefix named in the environment (CVC_DEPS_PREFIX/LIBCVC_DEPS_PREFIX/CVCPKG_PREFIX) now comes before this guess.MAGICK_CONFIGURE_PATHis set only to ashare\imagemagickthat holds.xmlconfig. The lookup also covers a<prefix>\debug\binlayout (<prefix>\share\imagemagick), which CI's Debug lane uses.New test:
magick_bootstrap_testThis is a separate executable, because the bootstrap runs once per process. During static initialization, before anything can initialize Magick, it removes the three
MAGICK_*variables and records whether Magick was already up. Then:ReadsXcWithoutMagickEnvironment(all platforms):cvc::init_imagemagick()alone makesxc:work.PointsMagickAtTheCoderModules(Windows): the variables it set name a directory withIM_MOD_RL_png_.dlland a config directory with.xmlfiles.RoundTripsPngAndJpegWithoutMagickEnvironment(Windows): PNG and JPEG are written and read back through Magick++ directly.cvc::imagereads both with stb first, so it can't prove that Magick's own decoders load.CvcImageRoundTripsTiffWithoutMagickEnvironment(Windows): TIFF goes throughcvc::image, which has no stb path for TIFF in either direction.CI sets the
MAGICK_*variables for the whole Windows ctest step, so until now no test exercised the lookup there. This PR leaves that CI step alone.Verification (Windows, MSVC 14.44, Release, shared, ImageMagick ON)
Build tree
C:\Users\tfx\src\cvc\build-magickboot, a sibling of thedepsprefix. Every run has noMAGICK_*and noCVC_DEPS_PREFIXunless the layout says so. The runs areimage_test(all 28 tests),cvc_cli_test --gtest_filter=*Vol2Img*:*Img2Vol*andmagick_bootstrap_test.build\bin+deps\binon PATH (normal dev run)CORE_RL_*.dllcopied intobuild\bin, so the loaded ImageMagick has no coders beside itImageTest.ReadsCmykInputAsRgb, both CvcCli cases, all 4 new tests (NoDecodeDelegate xc:,MAGICK_CODER_MODULE_PATH=...\build-magickboot\bin)CVC_DEPS_PREFIXMAGICK_*values CI setsctest -R "MagickBootstrapTest|ImageTest|CvcCliTest.(Vol2Img|Img2Vol)", with no variables set and one process per case: 34/34 passed. Linux and macOS weren't built locally. On those platforms the new executable only runs thexc:case, whichImageTest.ReadsCmykInputAsRgbalready does unguarded.