Repository navigation
fix(cpp): take EpsCopyInputStream::PopLimit token by rvalue reference - #28619
Closed
yashanil98 wants to merge 2 commits into
Closed
yashanil98 wants to merge 2 commits into
yashanil98 wants to merge 2 commits into
Conversation
LimitToken guards its payload with ASan memory poisoning. PopLimit accepted the token by value, so the compiler could place the by-value parameter in the same stack slot as the moved-from caller token; the move then poisoned that slot and PopLimit's read of it tripped a use-after-poison abort under ASan during descriptor initialization. Bind the token by rvalue reference instead, removing the extra copy and the shared-slot hazard. All three callers already pass std::move, and the body already consumes the token as an rvalue, so behavior is unchanged. Fixes protocolbuffers#27298.
shaod2
self-requested a review
July 21, 2026 17:20
shaod2
approved these changes
Jul 29, 2026
wperron
added a commit
to cloudflare/workerd
that referenced
this pull request
Nov 18, 2026
tracer-test aborts under ASan + UBSan before main runs, while protobuf registers the OTLP schemas' generated descriptors. EpsCopyInputStream::LimitToken poisons its token once it is used, and PopLimit() took the token by value. Clang 22 can give that parameter the stack slot of the moved-from token, so the move poisons the parameter and PopLimit() reads poisoned memory (protocolbuffers/protobuf#27298). protobuf 37.0 takes the token by rvalue reference (protocolbuffers/protobuf#28619). No stable release has the fix yet, so this freezes protobuf at 37.0-rc3 until 37.0 is out. Its dependencies are already at or below the versions workerd uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wperron
added a commit
to cloudflare/workerd
that referenced
this pull request
Nov 19, 2026
tracer-test aborts under ASan + UBSan before main runs, while protobuf registers the OTLP schemas' generated descriptors. EpsCopyInputStream::LimitToken poisons its token once it is used, and PopLimit() took the token by value. Clang 22 can give that parameter the stack slot of the moved-from token, so the move poisons the parameter and PopLimit() reads poisoned memory (protocolbuffers/protobuf#27298). protobuf 37.0 takes the token by rvalue reference (protocolbuffers/protobuf#28619). No stable release has the fix yet, so this freezes protobuf at 37.0-rc3 until 37.0 is out. Its dependencies are already at or below the versions workerd uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wperron
added a commit
to cloudflare/workerd
that referenced
this pull request
Nov 19, 2026
tracer-test aborts under ASan + UBSan before main runs, while protobuf registers the OTLP schemas' generated descriptors. EpsCopyInputStream::LimitToken poisons its token once it is used, and PopLimit() took the token by value. Clang 22 can give that parameter the stack slot of the moved-from token, so the move poisons the parameter and PopLimit() reads poisoned memory (protocolbuffers/protobuf#27298). protobuf 37.0 takes the token by rvalue reference (protocolbuffers/protobuf#28619). No stable release has the fix yet, so this freezes protobuf at 37.0-rc3 until 37.0 is out. Its dependencies are already at or below the versions workerd uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wperron
added a commit
to cloudflare/workerd
that referenced
this pull request
Nov 19, 2026
tracer-test aborts under ASan + UBSan before main runs, while protobuf registers the OTLP schemas' generated descriptors. EpsCopyInputStream::LimitToken poisons its token once it is used, and PopLimit() took the token by value. Clang 22 can give that parameter the stack slot of the moved-from token, so the move poisons the parameter and PopLimit() reads poisoned memory (protocolbuffers/protobuf#27298). protobuf 37.0 takes the token by rvalue reference (protocolbuffers/protobuf#28619). No stable release has the fix yet, so this freezes protobuf at 37.0-rc3 until 37.0 is out. Its dependencies are already at or below the versions workerd uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
EpsCopyInputStream::LimitToken guards its payload with ASan memory poisoning (poisoned when empty, unpoisoned while it holds a live token). PopLimit accepted the token by value:
With a by-value parameter, the compiler can place the parameter in the same stack slot as the moved-from caller token. The move assignment then poisons the moved-from token, i.e. the very slot the parameter occupies, and PopLimit reads it via
token(), which ASan reports as a use-after-poison abort. This reproduces beforemain()during static descriptor initialization when protobuf is built with-fsanitize=address(reported on aarch64 in #27298), e.g.:Take the token by rvalue reference (
LimitToken&& delta) instead. This removes the extra by-value copy and the shared-slot hazard: the token binds directly to the callers object, which is unpoisoned while live. All three callers (ParseLengthDelimitedInlined,ParseWithLengthInlined,ParseContext::ParseMessage) already passstd::move(old), and the body already consumes the token as an rvalue, so behavior is unchanged.Fixes #27298.
Test plan: the bug reproduces only under ASan (poisoning is a no-op otherwise) and protobuf has no in-repo ASan-poisoning regression harness for the parser, so this is verified by (1) the change being a by-value to rvalue-reference signature refactor with no behavioral change, all callers already moving the token, and (2) a full CMake/Ninja build plus the parsing test suites staying green:
tests --gtest_filter=*TcTable*:*Parse*:*WireFormat*:*Reflection*:*ExtensionSet*:*DynamicMessage*:*Arena*passes (~3000 tests, 0 failures). I do not have the reporters ASan+aarch64 toolchain to run the exact repro.