BUG: Do not compile NrrdIO's sampleIO.c demo into the library#6655
Merged
hjmjohnson merged 1 commit intoJul 17, 2026
Merged
Conversation
sampleIO.c is NrrdIO's usage demo and defines main(). Compiling it into
libITKNrrdIO makes the library export main(), so a downstream executable
linking ITK's NrrdIO alongside another main() (e.g. gtest_main) can
silently resolve to the demo instead of its own entry point.
Observed in BRAINSTools on ITK 6.0.0: GoogleTest executables became
NrrdIO's demoIO, so gtest_discover_tests enumerated zero tests and 17
unit tests silently vanished from a passing suite (413 -> 396). No error
at any layer; ITK 5.4.6 was unaffected because its vendored list predates
the change.
Three artifacts already vendored beside CMakeLists.txt describe this file
as a program rather than library code:
0-README.txt:93 "Tiny little command-line program demonstrating
the basic NrrdIO API."
sample-GNUmakefile ALL = libNrrdIO.a sampleIO
sampleIO : sampleIO.c ... -L. -lNrrdIO
NrrdIO_Srcs.txt 41 sources; omits sampleIO.c
Only nrrdio_SRCS listed it. It entered ITK via 9f0a5d3 (ENH: Update
NrrdIO from upstream); nothing in ITK builds it as an executable.
This is the minimal unblock for ITKv6 downstreams. The durable fix is
upstream in NrrdIO, where nrrdio_SRCS is now derived from NrrdIO_Srcs.txt
rather than maintained as a second hand-written copy; a future re-vendor
picks that up and this line does not return.
Verified with BRAINSTools 767ba471 built against ITK main, the only
variable being this change:
libITKNrrdIO-6.0.a main() definitions 1 -> 0
ImageCalculatorUtilsGTest demoIO -> gtest_main, 16 tests
registered tests 396 -> 413 (matches ITK 5.4.6)
Tool-Assisted: Claude Code (claude-opus-4-8)
Role: root-cause analysis, cross-project bisection
Contribution: traced the zero-test discovery to a main() exported by
libITKNrrdIO and identified sampleIO.c as its source.
dzenanz
approved these changes
Jul 17, 2026
dzenanz
left a comment
Member
There was a problem hiding this comment.
This problem is hilarious, despite being real.
hjmjohnson
marked this pull request as ready for review
July 17, 2026 13:19
Contributor
|
| Filename | Overview |
|---|---|
| Modules/ThirdParty/NrrdIO/src/NrrdIO/CMakeLists.txt | Removes sampleIO.c from the NrrdIO library source list so the vendored library no longer compiles the demo program's main() into ITKNrrdIO. |
Reviews (1): Last reviewed commit: "BUG: Do not compile NrrdIO's sampleIO.c ..." | Re-trigger Greptile
hjmjohnson
merged commit Jul 17, 2026
350ae6b
into
InsightSoftwareConsortium:main
18 of 20 checks passed
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.
sampleIO.cis NrrdIO's usage demo and definesmain(). Compiling it intolibITKNrrdIOmakes the library exportmain(), so downstream executables that link ITK's NrrdIO alongsidegtest_maincan silently resolve to the demo instead of their own entry point — on ITK 6.0.0 this silently deleted 17 BRAINSTools unit tests from a passing suite (413 → 396). One-line removal; ITK builds no executable from this file.This is the minimal unblock for ITKv6 downstreams. The durable fix is upstream in NrrdIO (
nrrdio_SRCSderived fromNrrdIO_Srcs.txtrather than kept as a second hand-written copy), which a future re-vendor picks up.Symptom — a GTest binary that was silently NrrdIO's demoIO
The executables build and run. They are simply the wrong program:
gtest_discover_testsruns the binary at build time to enumerate tests, receives Teem's banner instead of a test list, parses zero, and registers nothing. ctest then reports396 tests passed— success, with 17 tests absent rather than failing. Nothing errors or warns at any layer.ITK 5.4.6 is unaffected because its vendored list predates the change.
Why sampleIO.c is not library code
Three artifacts already vendored beside
CMakeLists.txtsay so:0-README.txt:93sample-GNUmakefile:56,74ALL = libNrrdIO.a sampleIO— two separate products;sampleIO : sampleIO.c ... -L. -lNrrdIOlinks against the libraryNrrdIO_Srcs.txtsampleIO.cOnly
nrrdio_SRCSinCMakeLists.txtlisted it — and that is the list the build executes.git grep sampleIOconfirms ITK has noadd_executablefor it; it built as nothing but an archive member.It entered ITK via 9f0a5d3 (
ENH: Update NrrdIO from upstream), inherited from NrrdIO's own hand-maintained list.Verification (local, BRAINSTools against ITK main)
BRAINSTools
767ba471built against ITKmain, this change the only variable:libITKNrrdIO-6.0.amain()definitionsImageCalculatorUtilsGTest --gtest_list_testsdemoIObannerRunning main() from gtest_main.cc, 16 testsctest -N)Found by a downstream build testbed that builds ITK consumers against a changed ITK; not visible to ITK's own CI, which does not build BRAINSTools' GTest suite.