1186 Commits

Author SHA1 Message Date
Michael Stapelberg
259e665f26 all: release v1.36.4
Change-Id: I0982b0714f2f250df0db242d6300cb5f44d999bf
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/643956
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v1.36.4
2025-01-24 05:07:33 -08:00
Michael Stapelberg
5f93d99439 internal_gengo: avoid allocations in rawDescGZIP() accessors
Use unsafeBytes in rawDescGZIP() as well, which is safe because our
CompressGZIP() does not write to the byte slice.

Store the result of CompressGZIP as a byte slice so that subsequent
calls do not cause any more allocations.

In http://go.dev/cl/638135, I asserted that rawDescGZIP() is rarely-used,
but after rolling out the change Google-internally, affected users made
me aware of a few programs that heavily access these descriptors.

Change-Id: Ieb5010ddc7b9ac6be88970321ff01a3d29e846bf
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/643276
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Nicolas Hillegeer <aktau@google.com>
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
Commit-Queue: Nicolas Hillegeer <aktau@google.com>
2025-01-17 06:01:45 -08:00
Josh Humphries
2005adbe0c reflect/protodesc: fix panic when working with dynamicpb
Improves on CL 642575 with a few additional checks to make
sure a panic doesn't occur even under unexpected conditions.

Fixes golang/protobuf#1671

Change-Id: I25bf1cfdf0b35b381cab603f9e06581b3b630d73
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/642975
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
2025-01-16 08:05:14 -08:00
Michael Stapelberg
aee8a9c419 internal_gengo: switch back from string literal to hex byte slice
It tourns out that Piper (the revision control system Google uses)
has a check that requires marking files containing non-UTF8 bytes
as binary, preventing textual review. We wanted to avoid this issue
in http://go.dev/cl/638135 and added \r to the escape set for Gerrit,
but we did not anticipate how strict other systems are in practice.

(I did not notice this issue earlier because the Piper check
does not trigger when sending a CL for Google-wide testing,
only when mailing a CL for review.)

It stands to reason that if our revision control and review systems
do not like string literals with non-UTF8 content, other systems
probably behave similarly. Hence, let’s revert that part of the change.
The key part of the change was to switch the type of the embedded
descriptor bytes from mutable []byte to immutable string.

I verified that the string literal remains in .rodata:

% (cd internal/reflection_test && \
  go test -c && \
  objdump -s -j .rodata reflection_test.test | grep '0a46696e')
 8e9fd0 0a46696e 7465726e 616c2f74 65737470  .Finternal/testp

The bytes printed above only occur once and match the bytes from
file_internal_testprotos_testeditions_testeditions_hybrid_test_hybrid_proto_rawDesc

Change-Id: I8e1bfe53a5bbf65abe7861a749ace37b215a8e28
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/642857
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
2025-01-15 07:58:57 -08:00
Michael Stapelberg
0c3cc2f8ed internal_gengo: use unsafe.StringData() to avoid a descriptor copy
This means our generated code requires Go 1.20+.
(Go Protobuf currently requires at least Go 1.21.)

Change-Id: Ie65be553bcb5912991d590104ff6b7c6a82b9c38
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/642055
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-01-15 07:05:16 -08:00
Michael Stapelberg
cc8d1c2ae2 internal_gengo: store raw descriptor in .rodata section
In Go, []byte literals go into the writable .data (or .noptrdata) section,
but string literals goes into the read-only .rodata section.

I verified that the contents move from .noptrdata to .rodata:

% (cd internal/reflection_test && \
  go test -c && \
  objdump -s -j .rodata reflection_test.test | grep '0a4669 6e')
 88bfd0 6e7370e8 070a4669 6e746572 6e616c2f  nsp...Finternal/

Change-Id: I87e190b41c02235abea1967eddca2f0262060ed9
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/638135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-01-15 06:58:56 -08:00
Michael Stapelberg
132f042b40 all: start v1.36.3-devel
Change-Id: Ic4aec2037f3460ac94d6caf11ece66dfbe4026c0
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/642856
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-15 06:27:33 -08:00
Michael Stapelberg
54ef969ef0 all: release v1.36.3
Change-Id: Icf5049d5341b55c6e2660122e5abae77f571359c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/642855
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
v1.36.3
2025-01-15 06:25:00 -08:00
Michael Stapelberg
7cbd915958 reflect/protodesc: fix panic when working with dynamicpb
Thanks to Joshua Humphries and Edward McFarlane for
the excellent bug report, reproducer and fix suggestion!

Fixes golang/protobuf#1669

Change-Id: I03df76f789e6e11b53396396a1f6b58bb3fb840b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/642575
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2025-01-15 00:22:37 -08:00
Michael Stapelberg
2f60868a73 proto: add example for GetExtension, SetExtension
(Adding an example to HasExtension as well seemed too much to me.)

The example message uses the same example names as the Generated Code Reference:
https://protobuf.dev/reference/go/go-generated-opaque/#extensions

The definition follows the Language Guide:
https://protobuf.dev/programming-guides/editions/#extensions

For golang/protobuf#1528

Change-Id: I7c5c4a0ac954678a5e0b10015374377b32bd7634
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/641876
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2025-01-13 00:43:16 -08:00
Michael Stapelberg
de043b94a8 runtime/protolazy: replace internal doc link with external link
Change-Id: Ie610db576e89a0ba48082eb375f8cef300236531
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/642015
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
2025-01-10 02:12:10 -08:00
Michael Stapelberg
42e0fa9022 all: split flags.ProtoLegacyWeak out of flags.ProtoLegacy
This is a no-op change in preparation of removing support for weak fields.
It allows users to keep enabling ProtoLegacy in general,
but also disable weak field support independently.

For golang/protobuf#1666

Change-Id: Ic3cb90d937e21a817ddbbb36029274be8b5f2513
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/641635
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-09 01:45:21 -08:00
Michael Stapelberg
5fee2a7676 internal/impl: remove unused exporter parameter
This parameter became unused with golang/protobuf#1640.

Change-Id: Iab50ffb757f5b6f017bc32c37b25294894c1c6d9
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/641019
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-08 00:38:30 -08:00
Michael Stapelberg
84924f745f internal/impl: switch to reflect.Value.IsZero
(Go Protobuf currently requires Go 1.21.)

Change-Id: I5b9f783bbd3611fedc544e1367cc3db9f0123494
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/641018
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-08 00:38:05 -08:00
Michael Stapelberg
fe8430d2b0 cmd/protoc-gen-go: remove json struct tags from unexported fields
This commit does not change behavior because the encoding/json
package ignores unexported fields. To encode a Protobuf message
into JSON, users should reach for protobuf/encoding/protojson.

With this change, the generated code (.pb.go files) passes go vet.
I also made the integration test run go vet so that we do not regress.

For golang/protobuf#1657

Fixes golang/protobuf#1658

Change-Id: I0a677d09e4517b2649bfcfe76a49194c7ccbb823
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/641036
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-08 00:24:50 -08:00
Michael Stapelberg
84f7738c4d internal/impl: clean up unneeded Go<1.12 MapRange() alternative
(Go Protobuf currently requires Go 1.21.)

Change-Id: Ib851304af2efe9845df260b700fcd577a375d3a8
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/641035
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-07 06:40:20 -08:00
Michael Stapelberg
9acc8f2c65 types/dynamicpb: switch atomicExtFiles to atomic.Uint64 type
(Go Protobuf currently requires Go 1.21.)

This guarantees correct alignment on stack-allocated values, too.

Change-Id: If713532c20326a7ee3f1dd5c77f49c1d52f6eb9a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/641017
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-07 06:34:52 -08:00
Michael Stapelberg
ad89419853 all: start v1.36.2-devel
Change-Id: I0dd6425a197595757db28fbdd84f81f048a5ef36
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/641016
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-07 00:15:50 -08:00
Michael Stapelberg
12c6ebd98e all: release v1.36.2
Change-Id: If65cf0b9b0dbf5ee87344d75c663c3305506f298
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/641015
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v1.36.2
2025-01-07 00:14:59 -08:00
Michael Stapelberg
8878926ea7 internal/impl: fix WhichOneof() to work with synthetic oneofs
This is the equivalent of CL 638495, but for the Opaque API.

While the behavior is the same for non-synthetic oneofs between
the Open Struct API and Opaque API, the behavior for synthetic oneofs
is not the same: Because the Opaque API uses a bitfield to store
presence, we need to use the Opaque presence check in WhichOneof().

This CL extends the testproto generator to use the protoc
command-line flag for the test3 testproto (which specifies
syntax = "proto3";), as the in-file api_level is only available
in .proto files using editions (but editions does not use synthetic
oneofs for optional fields, only proto3 does).

For golang/protobuf#1659

Change-Id: I0a1fd6e5fc6f96eeab043f966728ce2a14dbd446
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/638515
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2024-12-23 05:33:29 -08:00
Michael Stapelberg
c0c814fc1b all: start v1.36.1-devel
Change-Id: I7c57fd7034f1a55e25fb0e5654c0e9fcde14d4c4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/637938
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2024-12-23 04:48:38 -08:00
Michael Stapelberg
7fc5ff4e14 all: release v1.36.1
Change-Id: I551d270a4c0010bcdc87056715a1c38271ca2f5c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/637937
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v1.36.1
2024-12-23 04:47:17 -08:00
Michael Stapelberg
575aebf635 internal/impl: revert IsSynthetic() check to fix panic
This reverts change https://go.dev/cl/632735, in which
I misunderstood what the Protobuf documentation wanted to convey:
The quoted docs in CL 632735 refer to reflection for proto3 optional
fields, not to reflection for proto3 synthetic oneofs.

Synthetic oneofs should remain visible through reflection.
For the Open API, this change restores the old behavior.
For the Opaque API, another fix is needed and will be sent
in a separate, follow-up CL (follow golang/protobuf#1659).

For golang/protobuf#1659

Thanks to Joshua Humphries for the report and reproducer!

Change-Id: I3a924eed6d2425581adc65651395a68fc1576f4d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/638495
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-23 04:34:27 -08:00
Michael Stapelberg
ce4fa196c4 internal/errors: delete compatibility code for Go before 1.13
Currently, Go Protobuf requires Go 1.21.

Change-Id: I0b923f4f7732d54628f84e93adccc12f74f14e8e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/637475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
2024-12-18 08:09:14 -08:00
Michael Stapelberg
607da3e581 all: start v1.36.0-devel
Change-Id: Id47a99eafd700576f84f31f5f1b585c7aef8b0b4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/636676
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2024-12-16 08:48:44 -08:00
Michael Stapelberg
3b78ca86bd all: release v1.36.0
Change-Id: Ic27ded92dbbe7fad73c04e5dcc4ab16ab1fe40fd
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/636675
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v1.36.0
2024-12-16 08:46:32 -08:00
Michael Stapelberg
4cf3399ed2 src/google/protobuf: document UnmarshalJSON / API level behavior
For golang/protobuf#1657

Change-Id: Icdf7254bced1c0987ff2e969fd096d6eef3918f7
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/635139
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cassondra Foesch <cfoesch@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-16 00:38:13 -08:00
Michael Stapelberg
8edf9401bb reflect/protoreflect: use [] syntax to reference method
While godoc does not render comments within interface definitions,
using the [] syntax regardless helps with the replacement rules
we use to import Go Protobuf back into Google.

Change-Id: I0287ec3df5ba74261f563ce1117ab1e1be1fc270
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/635138
Reviewed-by: Cassondra Foesch <cfoesch@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-12-16 00:38:05 -08:00
Michael Stapelberg
5376513e4b proto: add reference to size semantics with lazy decoding to comment
For golang/protobuf#1657

Change-Id: I01007ed586d1833517735cf5f38cca302efb9801
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/635137
Reviewed-by: Cassondra Foesch <cfoesch@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-12-16 00:37:46 -08:00
Michael Stapelberg
560503ec5d compiler/protogen: allow overriding API level from --go_opt
For golang/protobuf#1657

In order to change the default API level, one can now specify:

    protoc […] --go_opt=default_api_level=API_HYBRID

To override the default API level for a specific file, use
the apilevelM mapping flag (similar to the M flag for import paths):

    protoc […] --go_opt=apilevelMhello.proto=API_HYBRID

(Similar to the M option.)

Change-Id: I44590e9aa4c034a5bb9c93ae32f4b11188e684a0
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/634818
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-12-11 03:23:13 -08:00
Michael Stapelberg
b64efdbc6e cmd/protoc-gen-go: generate _protoopaque variant for hybrid
For golang/protobuf#1657

Change-Id: I3c35fceeddedcd159a5adacec3113e12497ebd27
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/634817
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-11 03:23:02 -08:00
Michael Stapelberg
9eda3d5059 all: regenerate.bash for Opaque API
For golang/protobuf#1657

Change-Id: I8081e04050a38b0cb1b48ad674b683de61d36770
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/634816
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-12-11 03:17:04 -08:00
Michael Stapelberg
eb7b468655 all: Release the Opaque API
For golang/protobuf#1657

Change-Id: I7b2b0c30506706015ce278e6054439c9ad9ef727
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/634815
TryBot-Bypass: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Damien Neil <dneil@google.com>
2024-12-11 03:16:51 -08:00
Josh Humphries
5f5de338ee types/descriptorpb: regenerate using latest protobuf v29.1 release
This updates all generated code to match the contents of the latest
v29.1 release of Protobuf. The main significant change is that
SourceCodeInfo is now extendable (though in a very limited way).

This release of Protobuf includes new conformance tests that do not
pass with the latest version of this protobuf-go module. These have
been added to the list of known-failing tests. However all of them
are marked "required" in the conformance suite so should be likely
be addressed as soon as possible. (This change makes no attempt to
fix any of them.)

Change-Id: Ib554d393d7742b7a616af998eeab84a080a85e0e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/634015
Reviewed-by: Chressie Himpel <chressie@google.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-06 14:51:30 +00:00
Michael Stapelberg
bdcc7adc94 internal/impl: skip synthetic oneofs in messageInfo
Calling WhichOneof should not be possible for synthetic oneofs;
on the reflection level, these fields should work as if they
were regular fields, not as if they were oneofs:

> Reflection for proto3 optional fields should work properly. For example, a
> method like Reflection::HasField() should know to look for the hasbit for a
> proto3 optional field. It should not be fooled by the synthetic oneof into
> thinking that there is a case member for the oneof.

From the Protobuf docs at:
https://github.com/protocolbuffers/protobuf/blob/main/docs/implementing_proto3_presence.md#updating-reflection

This change was tested Google-internally as CL 701866153.

Change-Id: Id9500d4aa492acf4ebc6d2d84be07ed81201d2aa
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/632735
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-02 08:52:41 +00:00
Chressie Himpel
30f628eeb3 all: start v1.35.2-devel
Change-Id: I81e537e46e952d593ebd99dd80dad723a064477e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/627876
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
2024-11-14 09:41:35 +00:00
Chressie Himpel
c72053a906 all: release v1.35.2
Change-Id: I3e159766c6776efc92e93fca6d7b247d1bd3ece0
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/627875
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
v1.35.2
2024-11-14 09:28:32 +00:00
Michael Stapelberg
b98563540c internal/impl: fix TestMarshalMessageSetLazyRace (was a no-op!)
This test was accidentally migrated from proto.GetExtension to
proto.HasExtension in a semi-automated change and nobody noticed.

proto.HasExtension does not actually trigger lazy extension decoding.
I verified this using the dlv debugger:

% go test -tags protolegacy -c -gcflags "all=-N -l"
% dlv exec ./impl.test
Type 'help' for list of commands.
(dlv) r -test.run=TestMarshalMessageSetLazyRace -test.v
Process restarted with PID 3586699
(dlv) b TestMarshalMessageSetLazyRace
Breakpoint 1 set at 0xac9bf6 for google.golang.org/protobuf/internal/impl_test.TestMarshalMessageSetLazyRace() ./lazy_test.go:500
(dlv) c
=== RUN   TestMarshalMessageSetLazyRace
> [Breakpoint 1] google.golang.org/protobuf/internal/impl_test.TestMarshalMessageSetLazyRace() ./lazy_test.go:500 (hits goroutine(32):1 total:1) (PC: 0xac9bf6)
=> 500:	func TestMarshalMessageSetLazyRace(t *testing.T) {
(dlv) b ExtensionField.lazyInit
Breakpoint 2 set at 0x8da076 for google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit() ./codec_extension.go:123
(dlv) c
--- PASS: TestMarshalMessageSetLazyRace (4.07s)
PASS
Process 3586699 has exited with status 0
(dlv) exit

Note how breakpoint 2 is unexpectedly not hit!

Here is how the output changes with my fix:

% go test -tags protolegacy -c -gcflags "all=-N -l"
% dlv --check-go-version=false exec ./impl.test
Type 'help' for list of commands.
(dlv) r -test.run=TestMarshalMessageSetLazyRace -test.v
Process restarted with PID 3587344
(dlv) b TestMarshalMessageSetLazyRace
Breakpoint 1 set at 0xac9bf6 for google.golang.org/protobuf/internal/impl_test.TestMarshalMessageSetLazyRace() ./lazy_test.go:500
(dlv) c
=== RUN   TestMarshalMessageSetLazyRace
> [Breakpoint 1] google.golang.org/protobuf/internal/impl_test.TestMarshalMessageSetLazyRace() ./lazy_test.go:500 (hits goroutine(28):1 total:1) (PC: 0xac9bf6)
=> 500:	func TestMarshalMessageSetLazyRace(t *testing.T) {
(dlv) b ExtensionField.lazyInit
Breakpoint 2 set at 0x8da076 for google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit() ./codec_extension.go:123
(dlv) c
> [Breakpoint 2] google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit() ./codec_extension.go:123 (hits goroutine(68):1 total:4) (PC: 0x8da076)
> [Breakpoint 2] google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit() ./codec_extension.go:123 (hits goroutine(70):1 total:4) (PC: 0x8da076)
> [Breakpoint 2] google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit() ./codec_extension.go:123 (hits goroutine(58):1 total:4) (PC: 0x8da076)
> [Breakpoint 2] google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit() ./codec_extension.go:123 (hits goroutine(54):1 total:4) (PC: 0x8da076)
=> 123:	func (f *ExtensionField) lazyInit() {
(dlv) bt
0  0x00000000008da076 in google.golang.org/protobuf/internal/impl.(*ExtensionField).lazyInit
   at ./codec_extension.go:123
1  0x00000000008dac3e in google.golang.org/protobuf/internal/impl.(*ExtensionField).Value
   at ./codec_extension.go:180
2  0x000000000094e5d9 in google.golang.org/protobuf/internal/impl.(*extensionMap).Get
   at ./message_reflect.go:276
3  0x000000000095a2ee in google.golang.org/protobuf/internal/impl.(*messageState).Get
   at ./message_reflect_gen.go:90
4  0x0000000000890099 in google.golang.org/protobuf/proto.GetExtension
   at /usr/local/google/home/stapelberg/protobuf/proto/extension.go:90
5  0x0000000000aca7d4 in google.golang.org/protobuf/internal/impl_test.TestMarshalMessageSetLazyRace.func2.1
   at ./lazy_test.go:545
6  0x0000000000aca625 in google.golang.org/protobuf/internal/impl_test.TestMarshalMessageSetLazyRace.func2
   at ./lazy_test.go:550
7  0x00000000006001c1 in runtime.goexit
   at /usr/lib/google-golang/src/runtime/asm_amd64.s:1700

Change-Id: Ie7a8621064af412a1db7efb3ad6b8473f9db58e8
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/624416
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2024-11-04 08:59:09 +00:00
Michael Stapelberg
76135f99d5 proto: switch messageset_test to use makeMessages() injection point
This required renaming the extension fields to have distinct names, as
makeMessages() uses the protobuild package, which works with field names.

The makeMessages() function can be centrally extended with other variants of
testprotos (e.g. editions).

Change-Id: I68ef28baee674c6b53da8629c5ff7b2e1b92d4ff
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/624415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2024-11-04 08:58:59 +00:00
Michael Stapelberg
29947bbd16 internal/testprotos/test: add nested message field with [lazy=true]
This will be useful for a few different upcoming tests,
to be submitted in a follow-up CL.

Change-Id: I1fde9f4567b149141737a74c8448c2ee14946ae4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/623117
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
2024-10-30 12:39:37 +00:00
Michael Stapelberg
5c14d72191 encoding/prototext: use testmessages_test.go approach, too
With this change, we establish a similar mechanism in encoding/prototext as
already exists in the proto package: a testmessages_test.go which serves as an
extension point where one can inject more variants into the corpus of test
messages.

Change-Id: I9f83735a44e5fd2e4736f888aaca428e4cc8ed42
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/623116
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-29 14:35:35 +00:00
Michael Stapelberg
496557b1d5 proto: refactor equal_test from explicit table to use makeMessages()
This is important for test coverage: the makeMessages() function is where we
declare the various different test message types. Using this central function is
better than explicitly having to spell out all the various cases in the test
table.

This CL is roughly neutral in terms of lines changed, but actually increases
coverage: in the existing table, not every group of tests had coverage for all
cases (proto2, proto3, editions). This was difficult to spot previously, but now
the different test message types are now clearly spelled out (allTypesNoProto3).

Also, the test now prints the description and message types as subtest name.
This makes it easy to verify coverage by just reading the test output.

Change-Id: I08f541548d087233cbb4686785c456674371c2a3
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/623115
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-29 12:41:43 +00:00
Michael Stapelberg
0517e5afc7 testing/protocmp: document behavior when combining Ignore and Sort
fixes golang/protobuf#1652

Change-Id: I19af3714ec9fd9e54446bb0c3bd6815d90f11e10
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/622575
Reviewed-by: Christian Höppner <hoeppi@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
2024-10-28 09:07:43 +00:00
Michael Stapelberg
d14ebce888 all: implement strip_enum_prefix editions feature
This change required updating editions_defaults.binpb with
--edition_defaults_maximum=2024 so that we can use edition 2024 in our
testdata/enumprefix.proto test file.

For end users, this feature will only be available once:
1. protoc declares support for edition 2024 (expected early 2025).
2. protoc-gen-go declares support for edition 2024.

related to golang/protobuf#513

Change-Id: Ib8daeecae39ef32eff942279707d256c312f2a53
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/618979
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Mike Kruskal <mkruskal@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-10-23 09:04:58 +00:00
justinsb
fb995f184a encoding/protojson: allow missing value for Any of type Empty
Some other implementations do not send the value field when encoding
an Any representing a message of the Empty Well-Known-Type.

Fixes golang/protobuf#1620

Change-Id: I89bffd5f92656ba3ac462c0b6365ed4b49e6189d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/618395
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
2024-10-09 07:32:47 +00:00
Michael Stapelberg
d34023800d all: start v1.35.1-devel
Change-Id: I67979ea166a3fffba8c303fa1cc47f9eacb606b4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/618198
Reviewed-by: Lasse Folger <lassefolger@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-07 12:53:17 +00:00
Michael Stapelberg
158d2b331a all: release v1.35.1
Change-Id: Ia6b809a10e6d4f59a87b88268952347b5e24f573
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/618197
Reviewed-by: Lasse Folger <lassefolger@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v1.35.1
2024-10-07 12:51:58 +00:00
Michael Stapelberg
94e26c9ca9 all: start v1.35.0-devel
Change-Id: I094b4192fa383ae40f0d3f11050a570fda07fc15
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/618196
Reviewed-by: Lasse Folger <lassefolger@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v1.35.0
2024-10-07 12:36:36 +00:00
Michael Stapelberg
ac9817722e all: release v1.35.0
Change-Id: Ic0597f57619ea1e1e0d9dc85f08f26fa7b2c3389
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/618195
Reviewed-by: Lasse Folger <lassefolger@google.com>
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-07 12:36:27 +00:00
Reno Reckling
03df6c145d proto: Implement proto.Equal fast-path
Also adds better benchmark cases for large message where some fields are
actually populated.

This change was previously done in Google internal cl/660848520.

Change-Id: I682aae0c9c2850bfe7638de29ab743ad7d7b119a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/609035
Reviewed-by: Christian Höppner <hoeppi@google.com>
Reviewed-by: Cassondra Foesch <cfoesch@gmail.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-06 16:39:44 +00:00