Commit 792d359
internal/encoding/tag: use proto3 defaults if proto3
proto3 legacy struct field tags are improperly parsed as proto2,
resulting in fd.L1.EditionFeatures.IsFieldPresence set to true when it
should have been false. This causes coderFieldInfo.isPointer to be true
for said fields. When the encode process (particularly
MessageInfo.sizePointerSlow) sees isPointer=true for the field, it
attempts to interpret the field as a pointer, which results in a "fatal
error: checkptr: misaligned pointer conversion" runtime error if the
field address happens to not be pointer-aligned. This only happens if
building with -race/-asan/-msan as they enable checkptr.
To avoid this issue, parse from proto3 edition defaults if the proto3
key is found in the struct field tag.
Change-Id: Id81ab38fe7efd437d0748a485653d27b1acc3afb
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/716360
TryBot-Bypass: Michael Stapelberg <stapelberg@google.com>
Auto-Submit: Nicolas Hillegeer <aktau@google.com>
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>1 parent 4a45645 commit 792d359
2 files changed
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
124 | 131 | | |
125 | 132 | | |
126 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
40 | 44 | | |
0 commit comments