Skip to content

BUG: Fix cifti_tool's CIFTI extension search, which never advanced - #126

Draft
hjmjohnson wants to merge 3 commits into
stack/fix-axml-skip-depthfrom
stack/pr-fix-analyzer-leaks
Draft

hjmjohnson wants to merge 3 commits into
stack/fix-axml-skip-depthfrom
stack/pr-fix-analyzer-leaks

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Re-submission of #56, reverted from master on 2026-09-24. Content is
unchanged from the original.

Position 4 of 11 in the deep stack. Base: stack/fix-axml-skip-depth.

Based on the pull request above it in the stack, so the diff shown here is
this change alone. Merge the stack bottom-up.

Stack order

# branch base
1 stack/test-regression-coverage master
2 stack/pr-fix-alloc-null-checks stack/test-regression-coverage
3 stack/fix-axml-skip-depth stack/pr-fix-alloc-null-checks
4 stack/pr-fix-analyzer-leaks <- this PR stack/fix-axml-skip-depth
5 stack/pr-fix-sign-conversion stack/pr-fix-analyzer-leaks
6 stack/fix-fslio-64bit-arithmetic stack/pr-fix-sign-conversion
7 stack/fix-cifti-null-stream stack/fix-fslio-64bit-arithmetic
8 stack/pr-fix-calloc-transposed-args stack/fix-cifti-null-stream
9 stack/pr-fix-shorten-64-to-32 stack/pr-fix-calloc-transposed-args
10 stack/fix-image-read-complex-check stack/pr-fix-shorten-64-to-32
11 stack/pr-fix-xml-read-errors stack/fix-image-read-complex-check

The order is the order these changes sat on master before the revert, so
it builds and tests at every step.

Commits introduced by this PR
  • BUG: Fix cifti_tool's CIFTI extension search, which never advanced
  • ENH: Cover a CIFTI extension that is not first in the list

Ordering for all the re-submitted work is tracked in #84.

@hjmjohnson
hjmjohnson marked this pull request as ready for review September 24, 2026 12:18
@hjmjohnson
hjmjohnson marked this pull request as draft October 6, 2026 15:02
@hjmjohnson
hjmjohnson force-pushed the stack/pr-fix-analyzer-leaks branch from a0f6bd3 to eae24db Compare November 2, 2026 15:32
@hjmjohnson
hjmjohnson force-pushed the stack/fix-axml-skip-depth branch 2 times, most recently from cd03008 to fe446fe Compare November 6, 2026 14:59
@hjmjohnson
hjmjohnson force-pushed the stack/pr-fix-analyzer-leaks branch from eae24db to 5748f94 Compare November 6, 2026 14:59

@gdevenyi gdevenyi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Google Carbon

Verdict: Request Changes (Draft; unbundle hitchhiking #94 + defensive ext_list guard & test sanitizer regex)

Good catch in disp_cifti_extension (cifti/cifti_tool.c:214-219) — previously ext was initialized to nim->ext_list outside the loop and never incremented (ext->ecode checked ind times on element 0!), both misidentifying extension 0 as CIFTI whenever any later extension had NIFTI_ECODE_CIFTI and printing extension 0's payload instead!

Three items to address before merging:

  1. Unbundle PR #94 (.github/check_workflow_triggers.py): Currently hitchhikes in this branch; drop it when rebasing onto master.
  2. Guard nim->ext_list != NULL before indexing nim->ext_list[ind] (cifti/cifti_tool.c:215-216): Compare axio_read_cifti_ext (cifti/afni_xml_io.c), which validates nim->num_ext > 0 && nim->ext_list != NULL.
  3. Include ASan/LSan/UBSan in FAIL_REGULAR_EXPRESSION (cifti/CMakeLists.txt:52).

Comment thread cifti/cifti_tool.c Resolved
Comment thread cifti/CMakeLists.txt Resolved
@hjmjohnson
hjmjohnson force-pushed the stack/fix-axml-skip-depth branch from fe446fe to 977b40c Compare November 17, 2026 22:50
@hjmjohnson
hjmjohnson force-pushed the stack/pr-fix-analyzer-leaks branch from 5748f94 to 0472f7c Compare November 17, 2026 22:50
@hjmjohnson

Copy link
Copy Markdown
Member Author

Restacked on the updated #125. This PR's own fixes: the guarded extension search (2ff7385) and the sanitizer regex (0472f7c).

hjmjohnson and others added 3 commits November 19, 2026 13:00
A branch filter naming a branch that does not exist leaves the workflow
configured but never run, which looks the same as one that runs and
passes: no red check appears because no check appears at all. build.yml
sat dead behind a filter naming main on a repository whose branch is
master, and the only thing that found it was reading the file.

The check judges a filter only when every entry is a literal name, so a
release-* pattern or a branch that does not exist yet is left alone, and
it reports a name that resolves to nothing rather than one that merely
differs from the default.

(cherry picked from commit db038e9)
disp_cifti_extension() searched for the CIFTI extension with

    ext = nim->ext_list;
    for( ind = 0; ind < nim->num_ext; ind++ )
       if( ext->ecode == NIFTI_ECODE_CIFTI ) break;

ext is never advanced, so this tests the first extension num_ext times.
cifti_tool could only ever find a CIFTI extension that happened to be
first in the list; with any other extension ahead of it the tool
reported 'no CIFTI extension' for a file that has one.  It now indexes
ext_list[ind] and leaves ext NULL when there is no match, which also
avoids the read past the end of the list that a bare ext++ would have
introduced.

The same function opened its output stream before the 'no CIFTI
extension' check and returned without closing it; the early return now
closes the stream like the normal path does.

(cherry picked from commit d93153c)
cext_second_extension.nii carries a comment extension ahead of the
CIFTI one.  The test requires the extension's payload in the output and
forbids the 'no CIFTI extension' message, and the existing
unterminated-cext test still pins the first-position case, so neither a
search that always matches nor one that never does would pass.

(cherry picked from commit 2405d09)
@hjmjohnson
hjmjohnson force-pushed the stack/fix-axml-skip-depth branch from 977b40c to 22bb490 Compare November 19, 2026 19:01
@hjmjohnson
hjmjohnson force-pushed the stack/pr-fix-analyzer-leaks branch from 0472f7c to 0bc2c4f Compare November 19, 2026 19:01
@hjmjohnson

Copy link
Copy Markdown
Member Author

Restacked on the rebased #125 (0bc2c4f); no other changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants