Repository navigation
test: remove the UB PlotJuggler's ASan + UBSan lane trips on (1.0.1) - #245
Merged
Merged
Conversation
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
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
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.
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_testand the native parser module fixture: the byte writers shift auint64_tby 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 paststruct_size, so reading a slot before checkingstruct_sizeis still caught. I checked this by dropping thestruct_sizecheck fromMcpEndpointHostView::valid().PlaybackApiTest.SourceConversionIsOptionalOnLegacyHostsbuilds its legacy vtable the same way and gets the same change.Release: also bumps
VERSIONto 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). Oncev1.0.1is tagged, PlotJuggler'ssanitizers.ymlcan 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.struct_sizemakePlaybackVtable(). The reviewer confirmed a mutant that skips the check now fails without ASan tooDataProcessorsHostDecoderTest.RejectsATruncatedStructWithoutReadingPastItuses the same short-allocation patternVerified by the reviewer:
mcp_endpoint_host_testaborts on origin/main with the UBSan object-size report, and is clean on this branch.struct_sizecheck aborts with use-after-poison.check_feature_floors.pypasses.🤖 Generated with Claude Code
https://claude.ai/code/session_019HWZVLrTWPNZoqhipSkDAk