Skip to content

test: gate threaded-abort security tests on the AVX2 reader, not x86_64#460

Merged
osamu620 merged 1 commit into
mainfrom
fix/security-abort-test-avx2-guard
Jul 2, 2026
Merged

test: gate threaded-abort security tests on the AVX2 reader, not x86_64#460
osamu620 merged 1 commit into
mainfrom
fix/security-abort-test-avx2-guard

Conversation

@osamu620

@osamu620 osamu620 commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Problem

security_threaded_decode_abort_mt and security_threaded_decode_abort_color_mt verify that a code-block throw on a thread-pool worker is caught cleanly (no hang, no terminate). Their fixtures only throw on the AVX2 MagSgn reader — the scalar and NEON readers clamp the over-read and finish with garbage output instead.

The tests were registered for every x86_64 target, so an x86_64 build configured with -DENABLE_AVX2=OFF registered them and failed: the scalar reader never prints the PASS_REGULAR_EXPRESSION log line.

Fix

Register the tests only when the AVX2 block-decoder is actually compiled in: ENABLE_AVX2 plus a check_cxx_source_compiles probe for __AVX2__ under the active compile flags, mirroring the OPENHTJ2K_TRY_AVX2 && __AVX2__ gate in the source. This also keeps the tests off Emscripten and non-AVX2 x86 hosts, where the same clamping behaviour applies.

Verification

  • AVX2 build (Zen 5): both tests still registered, both pass.
  • x86_64 build with -DENABLE_AVX2=OFF -DENABLE_ARM_NEON=OFF: tests no longer registered (previously registered and failing).

🤖 Generated with Claude Code

https://claude.ai/code/session_01M9cKpzqghsLxJUu7kkyRAw

security_threaded_decode_abort_mt and security_threaded_decode_abort_color_mt
rely on the corrupted code-block actually throwing during decode, which only
the AVX2 MagSgn reader does — the scalar and NEON readers clamp the over-read
and finish with garbage.  The tests were registered for every x86_64 target,
so an x86_64 build configured with -DENABLE_AVX2=OFF registered them and
failed: the PASS_REGULAR_EXPRESSION log line is never printed on the scalar
path.

Replace the processor match with a compile check that mirrors the source
gate (OPENHTJ2K_TRY_AVX2 && __AVX2__): register the tests only when
ENABLE_AVX2 is on and __AVX2__ is defined under the active compile flags.

Verified: AVX2 build (Zen 5) still registers and passes the tests; an
x86_64 build with -DENABLE_AVX2=OFF no longer registers them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M9cKpzqghsLxJUu7kkyRAw
@osamu620
osamu620 merged commit 19a544b into main Jul 2, 2026
9 checks passed
@osamu620
osamu620 deleted the fix/security-abort-test-avx2-guard branch July 2, 2026 13:58
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.

1 participant