Skip to content

Conversation

@zhangskz
Copy link
Member

Any value field is a bytes field in OSS, and since cl/792909628 (#22956), _internal_mutable_*() accessors for string fields don't set hasbits. This can cause the hasbit to be missing for the value field of Any after calling PackFrom, which will serialize incorrectly.

This change also includes fixes to any_test, which failed to catch this bug. We got unlucky, and every test which checked a roundtrip PackFrom -> UnpackTo for an Any field reused the same Any object, calling MessageLite::ParseFromString (which Clear()s it) on the same object. However, Clear() skips string fields whose hasbits are not set. This meant the string value field of the Any was not cleared, since its hasbit had not been properly set by PackFrom. So even though the Any value skipped serializing its value, the reused Any object still contained the expected string value serialization of the submessage, and UnpackTo worked correctly.

The culprit change was adopted in release 33.0, so it will need to be patched to this version.

See #24258.

Fixes #24258

PiperOrigin-RevId: 828299368

Cherry-pick of 407323f

`Any` `value` field is a `bytes` field in OSS, and since cl/792909628 (#22956), `_internal_mutable_*()` accessors for string fields don't set hasbits. This can cause the hasbit to be missing for the `value` field of `Any` after calling `PackFrom`, which will serialize incorrectly.

This change also includes fixes to `any_test`, which failed to catch this bug. We got unlucky, and every test which checked a roundtrip `PackFrom` -> `UnpackTo` for an `Any` field reused the same `Any` object, calling `MessageLite::ParseFromString` (which `Clear()`s it) on the same object. However, `Clear()` skips string fields whose hasbits are not set. This meant the `string value` field of the `Any` was not cleared, since its hasbit had not been properly set by `PackFrom`. So even though the `Any` value skipped serializing its value, the reused `Any` object still contained the expected `string value` serialization of the submessage, and `UnpackTo` worked correctly.

The culprit change was adopted in release 33.0, so it will need to be patched to this version.

See #24258.

Fixes #24258

PiperOrigin-RevId: 828299368
@zhangskz zhangskz disabled auto-merge November 12, 2025 19:46
This build has become a severe bottleneck in our CI.  To avoid this in the future, always use whatever pre-install version is on the mac runners.  The linux tests will cover specific versions of PHP still.

PiperOrigin-RevId: 818864695
@zhangskz zhangskz merged commit 59db671 into 33.x Nov 12, 2025
223 checks passed
@zhangskz zhangskz deleted the cp-any-hasbit-33 branch November 12, 2025 20:36
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