Skip to content

test: remove the UB PlotJuggler's ASan + UBSan lane trips on (1.0.1) - #245

Merged
facontidavide merged 4 commits into
mainfrom
fix/ubsan-test-ub
Nov 16, 2026
Merged

facontidavide merged 4 commits into
mainfrom
fix/ubsan-test-ub

Conversation

@facontidavide

@facontidavide facontidavide commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Two SDK test helpers have undefined behaviour that PlotJuggler's ASan + UBSan lane catches. Both tests are excluded from that lane today. Test-only change; the SDK library is unchanged.

  • parser_module_abi_test and the native parser module fixture: the byte writers shift a uint64_t by 64 (put(3, 0, 17) reaches byte index 8). Bytes past the eighth are now written as zero, which is what the descriptor expects there.
  • mcp_endpoint_host_test (TooSmallStructSizeIsUnbound) read a vtable through an allocation smaller than its type. It now allocates a whole vtable and ASan-poisons the bytes past struct_size, so reading a slot before checking struct_size is still caught. I checked this by dropping the struct_size check from McpEndpointHostView::valid().
  • PlaybackApiTest.SourceConversionIsOptionalOnLegacyHosts builds its legacy vtable the same way and gets the same change.

Release: also bumps VERSION to 1.0.1, with a changelog entry (Host contract: unchanged). The CLAUDE.md policy says test-only changes get no bump, but PlotJuggler builds these tests from the release tarball, so the fix only reaches its sanitizer lane through a release (requested by the maintainer). Once v1.0.1 is tagged, PlotJuggler's sanitizers.yml can drop its ASan test exclusion.

Review (/davide-review, small tier: 1 Opus reviewer, xhigh)

The reviewer built the tests with clang-21 -fsanitize=address,undefined, ran them, and also ran mutation checks.

# Finding Decision Why
1 The legacy playback vtable copied one whose slot was already null, so without ASan the test never needed struct_size Fixed Starts from makePlaybackVtable(). The reviewer confirmed a mutant that skips the check now fails without ASan too
2 DataProcessorsHostDecoderTest.RejectsATruncatedStructWithoutReadingPastIt uses the same short-allocation pattern Not applied Clean under clang-21 ASan+UBSan (43/43); to watch if clang-22 trips on it

Verified by the reviewer:

  • mcp_endpoint_host_test aborts on origin/main with the UBSan object-size report, and is clean on this branch.
  • A slot read before the struct_size check aborts with use-after-poison.
  • check_feature_floors.py passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_019HWZVLrTWPNZoqhipSkDAk

facontidavide and others added 3 commits November 16, 2026 06:00
The aliased-scalar-names helpers in parser_module_abi_test and the native
parser module fixture write each field byte as value >> (8 * index), and
put(3, 0, 17) reaches index 8. UBSan aborts both tests in PlotJuggler's ASan +
UBSan lane: "shift exponent 64 is too large for 64-bit type 'uint64_t'".
Bytes past the eighth are now written as zero, which is what the descriptor
expects there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019HWZVLrTWPNZoqhipSkDAk
…isoned tail

TooSmallStructSizeIsUnbound allocated only the bytes struct_size claims and
read them through PJ_mcp_endpoint_host_vtable_t, an object too small for its
type. UBSan's object-size check aborts mcp_endpoint_host_test in PlotJuggler's
ASan + UBSan lane: "member access within address ... with insufficient space
for an object of type 'const PJ_mcp_endpoint_host_vtable_t'". The test now
allocates a whole vtable and ASan-poisons everything past struct_size, so a
slot read made before checking struct_size is still caught (use-after-poison;
checked by dropping the struct_size check from McpEndpointHostView::valid()).

PlaybackApiTest.SourceConversionIsOptionalOnLegacyHosts builds its legacy
vtable the same way and passes today only because the optimizer hides the
allocation size; it gets the same change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019HWZVLrTWPNZoqhipSkDAk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019HWZVLrTWPNZoqhipSkDAk
@facontidavide facontidavide changed the title test: remove the UB that PlotJuggler's ASan + UBSan lane trips on test: remove the UB PlotJuggler's ASan + UBSan lane trips on (1.0.1) Nov 16, 2026
The truncated legacy vtable copied the one whose to_display_time_for_source
was already null, so without ASan the struct_size check was never needed for
the assertion to hold. It now starts from a full vtable: only struct_size
hides the slot, so a view reading it unchecked fails in every build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019HWZVLrTWPNZoqhipSkDAk
@facontidavide
facontidavide merged commit ffd749a into main Nov 16, 2026
7 checks passed
@facontidavide
facontidavide deleted the fix/ubsan-test-ub branch November 16, 2026 19:39
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