Skip to content

Conversation

austinderek
Copy link

For non-formatted strings "fmt.Errorf" and "errors.New" have the same result,
but the former is slower and allocates more memory.

So it is better to call "errors.New" directly for non-formatted strings.


🔄 This is a mirror of upstream PR golang#75719

callthingsoff and others added 30 commits September 28, 2025 21:38
When applying relocations, a malformed ELF file can provide an offset
that, when added to the relocation size, overflows. This wrapped-around
value could then incorrectly pass the bounds check, leading to a panic
when the slice is accessed with the original large offset.

This change eliminates the manual bounds and overflow checks
and writes a relocation to slice by calling putUint.

The putUint helper function centralizes the logic for validating slice
access, correctly handling both out-of-bounds and integer overflow conditions.
This simplifies the relocation code and improves robustness when parsing
malformed ELF files.

Fixes golang#75516

Change-Id: I00d806bf5501a9bf70200585ba4fd0475d7b2ddc
GitHub-Last-Rev: 4914431
GitHub-Pull-Request: golang#75522
Reviewed-on: https://go-review.googlesource.com/c/go/+/705075
Reviewed-by: Florian Lehner <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Junyang Shao <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Commit-Queue: Ian Lance Taylor <[email protected]>
CL 706175 removed the NOFRAME directive from _rt0_arm64_netbsd but
did not change the BL instruction to a JMP instruction. This causes the
frame pointer to be stored on the stack, this making direct load from
RSP to be off by 8 bytes.

Cq-Include-Trybots: luci.golang.try:gotip-netbsd-arm64
Change-Id: I0c212fbaba74cfce508f961090dc6e66154c3054
Reviewed-on: https://go-review.googlesource.com/c/go/+/707675
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Michael Pratt <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
To make the code more readable and improve performance:

goos: darwin
goarch: arm64
pkg: encoding/xml
cpu: Apple M4
                 │     old     │                 new                 │
                 │   sec/op    │   sec/op     vs base                │
Marshal-10         1.902µ ± 1%   1.496µ ± 1%  -21.37% (p=0.000 n=10)
Unmarshal-10       3.877µ ± 1%   3.418µ ± 2%  -11.84% (p=0.000 n=10)
HTMLAutoClose-10   1.314µ ± 3%   1.333µ ± 1%        ~ (p=0.270 n=10)
geomean            2.132µ        1.896µ       -11.07%

                 │     old      │                  new                  │
                 │     B/op     │     B/op      vs base                 │
Marshal-10         5.570Ki ± 0%   5.570Ki ± 0%       ~ (p=1.000 n=10) ¹
Unmarshal-10       7.586Ki ± 0%   7.555Ki ± 0%  -0.41% (p=0.000 n=10)
HTMLAutoClose-10   3.496Ki ± 0%   3.496Ki ± 0%       ~ (p=1.000 n=10) ¹
geomean            5.286Ki        5.279Ki       -0.14%
¹ all samples are equal

                 │    old     │                 new                 │
                 │ allocs/op  │ allocs/op   vs base                 │
Marshal-10         23.00 ± 0%   23.00 ± 0%       ~ (p=1.000 n=10) ¹
Unmarshal-10       185.0 ± 0%   184.0 ± 0%  -0.54% (p=0.000 n=10)
HTMLAutoClose-10   93.00 ± 0%   93.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean            73.42        73.28       -0.18%
¹ all samples are equal

Updates golang#62121

Change-Id: Ie458e7458d4358c380374571d380ca3b65ca87bb
GitHub-Last-Rev: bb6bb30
GitHub-Pull-Request: golang#75483
Reviewed-on: https://go-review.googlesource.com/c/go/+/704215
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Keith Randall <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
As with other DWARF tests, don't run TestFlagW on platforms
where executables don't have a DWARF symbol table.

Fixes golang#75585

Change-Id: I81014bf59b15e30ac1b2a7d24a52f9647db46c26
Reviewed-on: https://go-review.googlesource.com/c/go/+/706418
Reviewed-by: Cherry Mui <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
The pcln.cutab slice holds uint32 elements, as can be seen in the
runtime.moduledata type. The slice was being created with the len
(and cap) set to the size of the slice, which means that the count
was four times too large. This patch sets the correct len/cap.

This doesn't matter for the runtime because nothing looks at
the len of cutab. Since the incorrect len is larger, all valid
indexes remain valid. Using the correct length means that more
invalid indexes will be caught at run time, but such cases are unlikely.
Still, using the correct len is less confusing.

While we're here use the simpler sliceSym for pcln.pclntab.

Change-Id: I09f680b3287467120d994b171c86c784085e3d27
Reviewed-on: https://go-review.googlesource.com/c/go/+/707595
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
Solaris linker's -S has a different meaning.

Fixes golang#75637.

Change-Id: I51e641d5bc6d7f64ab5aa280090c70ec787a1fbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/707096
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: David Chase <[email protected]>
Quote the protocols sent by the client when returning the ALPN
negotiation error message.

Fixes CVE-2025-58189
Fixes golang#75652

Change-Id: Ie7b3a1ed0b6efcc1705b71f0f1e8417126661330
Reviewed-on: https://go-review.googlesource.com/c/go/+/707776
Auto-Submit: Roland Shoemaker <[email protected]>
Reviewed-by: Neal Patel <[email protected]>
Reviewed-by: Nicholas Husin <[email protected]>
Auto-Submit: Nicholas Husin <[email protected]>
Reviewed-by: Nicholas Husin <[email protected]>
TryBot-Bypass: Roland Shoemaker <[email protected]>
Reviewed-by: Daniel McCarney <[email protected]>
GetFileSizeEx was generated before mkwinsyscall was updated to use
SyscallN. Regenerate to use the new style.

Fixes golang#75642

Change-Id: Ia473a167633b67fb75b5762d693848ecee425a7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/707615
Reviewed-by: Roland Shoemaker <[email protected]>
Auto-Submit: Dmitri Shuralyov <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
Binutils defaults to exporting all symbols when building a Windows DLL.
To avoid that we were marking symbols with __declspec(dllexport) in
the cgo-generated headers, which instructs ld to export only those
symbols. However, that approach makes the headers hard to reuse when
importing the resulting DLL into other projects, as imported symbols
should be marked with __declspec(dllimport).

A better approach is to generate a .def file listing the symbols to
export, which gets the same effect without having to modify the headers.

Updates golang#30674
Fixes golang#56994

Change-Id: I22bd0aa079e2be4ae43b13d893f6b804eaeddabf
Reviewed-on: https://go-review.googlesource.com/c/go/+/705776
Reviewed-by: Michael Knyszek <[email protected]>
Reviewed-by: Junyang Shao <[email protected]>
Reviewed-by: Than McIntosh <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
WSASend and WSARecv functions capture the WSABuf structure before
returning, so there is no need to keep a copy of it in the
operation structure.

Write and Read functions don't need it, they can operate directly
on the byte slice.

To be on the safe side, pin the input byte slice so that stack-allocated
slices don't get moved while overlapped I/O is in progress.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-amd64-race
Change-Id: I474bed94e11acafa0bdd8392b5dcf8993d8e1ed5
Reviewed-on: https://go-review.googlesource.com/c/go/+/704155
Reviewed-by: Junyang Shao <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Damien Neil <[email protected]>
Change-Id: I9b1fa390434dbda7d49a36b0114c68f942c11d3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/707575
Auto-Submit: Ian Lance Taylor <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
It taks north of 130µs on my machine, which is enough to be worth
shaving off at init time.

Change-Id: I6a6a696463de228bc3e7b9ca10c12ddbaabdf384
Reviewed-on: https://go-review.googlesource.com/c/go/+/707695
Auto-Submit: Filippo Valsorda <[email protected]>
Reviewed-by: Daniel McCarney <[email protected]>
Reviewed-by: Roland Shoemaker <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
Heavily inspired by the BoringSSL implementation.

Change-Id: I6a6a6964b22826d54700c8b3d555054163cef5fe
Co-authored-by: Daniel Morsing <[email protected]>
Cq-Include-Trybots: luci.golang.try:gotip-linux-s390x,gotip-linux-ppc64_power10,gotip-linux-ppc64le_power10,gotip-linux-ppc64le_power8,gotip-linux-arm,gotip-darwin-arm64_15,gotip-windows-arm64,gotip-freebsd-amd64
Reviewed-on: https://go-review.googlesource.com/c/go/+/703015
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Roland Shoemaker <[email protected]>
Reviewed-by: Daniel McCarney <[email protected]>
Auto-Submit: Filippo Valsorda <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
…xecIO

execIO callers should be agnostic to the fact that it uses an overlapped
object. This will unlock future optimizations and simplifications.

Change-Id: I0a58d992101fa74ac75e3538af04cbc44156f0d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/704175
Reviewed-by: Damien Neil <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Junyang Shao <[email protected]>
Use a sync.Pool to reuse the overlapped object passed to the different
Windows syscalls instead of keeping two of them in the FD struct.

This reduces the size of the FD struct from 248 to 152 bytes.

While here, pin the overlapped object for the duration of the overlapped
IO operation to comply with the memory safety rules.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-amd64-race
Change-Id: I0161d163f681fe94b822c0c885aaa42c449e5342
Reviewed-on: https://go-review.googlesource.com/c/go/+/704235
Reviewed-by: Damien Neil <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Junyang Shao <[email protected]>
These features have been standardized since at least Wasm 2.0.
Always enable them.

The corresponding GOWASM settings are now no-op.

Change-Id: I0e59f21696a69a4e289127988aad629a720b002b
Reviewed-on: https://go-review.googlesource.com/c/go/+/707855
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: David Chase <[email protected]>
… internal linking

ARM64_RELOC_POINTER_TO_GOT is the arm64 version of X86_64_RELOC_GOT, which has been support
for many years now.

The standard library still doesn't need it, but I've found it necessary
when statically linking against a library I own.

Change-Id: I8eb7bf3c74aed663a1fc00b5dd986057130f7f7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/703315
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
…ernal linking

ARM64_RELOC_SUBTRACTOR is the arm64 version of X86_64_RELOC_SUBTRACTOR, which
has been recently implemented in CL 660715.

The standard library still doesn't need it, but I've found it necessary
when statically linking against a library I own.

Change-Id: I138281b12f2304e3673f7dc92f7137e48bf68fdd
Reviewed-on: https://go-review.googlesource.com/c/go/+/703316
Reviewed-by: Carlos Amedee <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
Fixes golang#51945

Change-Id: Icda169782e796578eba728938134a85b5827d3b6
GitHub-Last-Rev: c6ff335
GitHub-Pull-Request: golang#75621
Reviewed-on: https://go-review.googlesource.com/c/go/+/707235
Reviewed-by: Carlos Amedee <[email protected]>
Reviewed-by: Damien Neil <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Sean Liao <[email protected]>
This is necessary specifically to set the value of `debug.decoratemappings`
sufficiently early in the startup sequence that all memory ranges allocated
can be named appropriately using the new Linux-specific naming API
introduced in golang#71546.

Example output (on ARM64):
https://gist.github.com/9muir/3667654b9c3f52e8be92756219371672

Fixes: golang#75324

Change-Id: Ic0b16233f54a45adef1660c4d0df59af2f5af86a
Reviewed-on: https://go-review.googlesource.com/c/go/+/703476
Auto-Submit: Michael Knyszek <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
The first arg of a generic function is the dictionary. This dictionary
is never nil, but it gets a nil check becuase the dict arg is treated as
a slice during construction.

cmp.Compare[go.shape.int] was:

00006 (+41) TESTB AX, (AX)
00007 (+52) CMPQ CX, BX
00008 (52) JGT 14
00009 (+55) JGE 12
00010 (+56) MOVL $1, AX
00011 (56) RET
00012 (+58) XORL AX, AX
00013 (58) RET
00014 (+53) MOVQ $-1, AX
00015 (53) RET

Note how the function begins with a TESTB that loads the dict to perform
the nil check.

This CL eliminates that nil check.

For most generic functions, this doesn't matter too much, but not
infrequently are generic functions written which never actually use the
dictionary (like cmp.Compare), so I suspect this might help in hot code
to avoid repeatedly touching the dictionary in memory, and in cases
where the generic function is not inlined (and thus the dict dropped).

compilecmp shows these changes (deduped):

cmp.Compare[go.shape.float64] 73 -> 72  (-1.37%)
cmp.Compare[go.shape.int] 26 -> 24  (-7.69%)
cmp.Compare[go.shape.int32] 25 -> 23  (-8.00%)
cmp.Compare[go.shape.int64] 26 -> 24  (-7.69%)
cmp.Compare[go.shape.string] 142 -> 141  (-0.70%)
cmp.Compare[go.shape.uint16] 26 -> 24  (-7.69%)
cmp.Compare[go.shape.uint] 26 -> 24  (-7.69%)
cmp.Compare[go.shape.uint32] 25 -> 23  (-8.00%)
cmp.Compare[go.shape.uint64] 26 -> 24  (-7.69%)
cmp.Compare[go.shape.uint8] 25 -> 23  (-8.00%)
cmp.Compare[go.shape.uintptr] 26 -> 24  (-7.69%)
cmp.Less[go.shape.float64] 35 -> 34  (-2.86%)
cmp.Less[go.shape.int32] 8 -> 6  (-25.00%)
cmp.Less[go.shape.int64] 9 -> 7  (-22.22%)
cmp.Less[go.shape.int] 9 -> 7  (-22.22%)
cmp.Less[go.shape.string] 112 -> 110  (-1.79%)
cmp.Less[go.shape.uint16] 9 -> 7  (-22.22%)
cmp.Less[go.shape.uint32] 8 -> 6  (-25.00%)
cmp.Less[go.shape.uint64] 9 -> 7  (-22.22%)
internal/synctest.Associate[go.shape.struct 114 -> 113  (-0.88%)
internal/trace.(*dataTable[go.shape.uint64,go.shape.string]).insert 805 -> 791  (-1.74%)
internal/trace.(*dataTable[go.shape.uint64,go.shape.struct 858 -> 852  (-0.70%)
main.(*gState[go.shape.int64]).stop 2111 -> 2085  (-1.23%)
main.(*gState[go.shape.int64]).unblock 941 -> 923  (-1.91%)
runtime.fmax[go.shape.float32] 85 -> 83  (-2.35%)
runtime.fmax[go.shape.float64] 89 -> 87  (-2.25%)
runtime.fmin[go.shape.float32] 85 -> 83  (-2.35%)
runtime.fmin[go.shape.float64] 89 -> 87  (-2.25%)
slices.BinarySearch[go.shape.[]string,go.shape.string] 346 -> 337  (-2.60%)
slices.Concat[go.shape.[]uint8,go.shape.uint8] 462 -> 453  (-1.95%)
slices.ContainsFunc[go.shape.[]*cmd/vendor/github.com/google/pprof/profile.Sample,go.shape.*uint8] 170 -> 169  (-0.59%)
slices.ContainsFunc[go.shape.[]*debug/dwarf.StructField,go.shape.*uint8] 170 -> 169  (-0.59%)
slices.ContainsFunc[go.shape.[]*go/ast.Field,go.shape.*uint8] 170 -> 169  (-0.59%)
slices.ContainsFunc[go.shape.[]string,go.shape.string] 186 -> 181  (-2.69%)
slices.Contains[go.shape.[]*cmd/compile/internal/syntax.BranchStmt,go.shape.*cmd/compile/internal/syntax.BranchStmt] 44 -> 42  (-4.55%)
slices.Contains[go.shape.[]cmd/compile/internal/syntax.Type,go.shape.interface 223 -> 219  (-1.79%)
slices.Contains[go.shape.[]crypto/tls.CurveID,go.shape.uint16] 44 -> 42  (-4.55%)
slices.Contains[go.shape.[]crypto/tls.SignatureScheme,go.shape.uint16] 44 -> 42  (-4.55%)
slices.Contains[go.shape.[]*go/ast.BranchStmt,go.shape.*go/ast.BranchStmt] 44 -> 42  (-4.55%)
slices.Contains[go.shape.[]go/types.Type,go.shape.interface 223 -> 219  (-1.79%)
slices.Contains[go.shape.[]int,go.shape.int] 44 -> 42  (-4.55%)
slices.Contains[go.shape.[]string,go.shape.string] 223 -> 219  (-1.79%)
slices.Contains[go.shape.[]uint16,go.shape.uint16] 44 -> 42  (-4.55%)
slices.Contains[go.shape.[]uint8,go.shape.uint8] 44 -> 42  (-4.55%)
slices.Insert[go.shape.[]string,go.shape.string] 1189 -> 1170  (-1.60%)
slices.medianCmpFunc[go.shape.struct 1118 -> 1113  (-0.45%)
slices.medianCmpFunc[go.shape.struct 1214 -> 1209  (-0.41%)
slices.medianCmpFunc[go.shape.struct 889 -> 887  (-0.22%)
slices.medianCmpFunc[go.shape.struct 901 -> 874  (-3.00%)
slices.order2Ordered[go.shape.float64] 89 -> 87  (-2.25%)
slices.order2Ordered[go.shape.uint16] 75 -> 70  (-6.67%)
slices.partialInsertionSortOrdered[go.shape.string] 1115 -> 1110  (-0.45%)
slices.partialInsertionSortOrdered[go.shape.uint16] 358 -> 352  (-1.68%)
slices.partitionEqualOrdered[go.shape.int] 208 -> 203  (-2.40%)
slices.partitionEqualOrdered[go.shape.int32] 208 -> 198  (-4.81%)
slices.partitionEqualOrdered[go.shape.int64] 208 -> 203  (-2.40%)
slices.partitionEqualOrdered[go.shape.uint32] 208 -> 198  (-4.81%)
slices.partitionEqualOrdered[go.shape.uint64] 208 -> 203  (-2.40%)
slices.partitionOrdered[go.shape.float64] 538 -> 533  (-0.93%)
slices.partitionOrdered[go.shape.int] 437 -> 427  (-2.29%)
slices.partitionOrdered[go.shape.int64] 437 -> 427  (-2.29%)
slices.partitionOrdered[go.shape.uint16] 447 -> 442  (-1.12%)
slices.partitionOrdered[go.shape.uint64] 437 -> 427  (-2.29%)
slices.rotateCmpFunc[go.shape.struct 1045 -> 1029  (-1.53%)
slices.rotateCmpFunc[go.shape.struct 1205 -> 1163  (-3.49%)
slices.rotateCmpFunc[go.shape.struct 1226 -> 1176  (-4.08%)
slices.rotateCmpFunc[go.shape.struct 1322 -> 1272  (-3.78%)
slices.rotateCmpFunc[go.shape.struct 1419 -> 1400  (-1.34%)
slices.rotateCmpFunc[go.shape.*uint8] 549 -> 538  (-2.00%)
slices.rotateLeft[go.shape.string] 603 -> 588  (-2.49%)
slices.rotateLeft[go.shape.uint8] 255 -> 250  (-1.96%)
slices.siftDownOrdered[go.shape.int] 181 -> 171  (-5.52%)
slices.siftDownOrdered[go.shape.int32] 181 -> 171  (-5.52%)
slices.siftDownOrdered[go.shape.int64] 181 -> 171  (-5.52%)
slices.siftDownOrdered[go.shape.string] 614 -> 592  (-3.58%)
slices.siftDownOrdered[go.shape.uint32] 181 -> 171  (-5.52%)
slices.siftDownOrdered[go.shape.uint64] 181 -> 171  (-5.52%)
time.parseRFC3339[go.shape.string] 1774 -> 1758  (-0.90%)
unique.(*canonMap[go.shape.struct 280 -> 276  (-1.43%)
unique.clone[go.shape.struct 311 -> 293  (-5.79%)
weak.Make[go.shape.6880e4598856efac32416085c0172278cf0fb9e5050ce6518bd9b7f7d1662440] 136 -> 134  (-1.47%)
weak.Make[go.shape.struct 136 -> 134  (-1.47%)
weak.Make[go.shape.uint8] 136 -> 134  (-1.47%)

Change-Id: I43dcea5f2aa37372f773e5edc6a2ef1dee0a8db7
Reviewed-on: https://go-review.googlesource.com/c/go/+/706655
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: David Chase <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Auto-Submit: Keith Randall <[email protected]>
… types

Implement all agreed upon types, using IANA's listed media types to decide
when there is a disagreement in type.  Except in the case of `.wav` where
`audio/wav` is used.

Fixes golang#69530

Change-Id: Iec99a6ceb534073be83c8390f48799bec3e4cfc7
GitHub-Last-Rev: e314c5e
GitHub-Pull-Request: golang#69533
Reviewed-on: https://go-review.googlesource.com/c/go/+/614376
Reviewed-by: Damien Neil <[email protected]>
Reviewed-by: Emmanuel Odeke <[email protected]>
Auto-Submit: Sean Liao <[email protected]>
Reviewed-by: Sean Liao <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
This change is mostly gardening. It simplifies ParseMediaType and its
helper functions and reduces the amount of allocations they incur.

Here are some benchmark results:

goos: darwin
goarch: amd64
pkg: mime
cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
                      │     old     │                new                 │
                      │   sec/op    │   sec/op     vs base               │
ParseMediaType-8        55.26µ ± 1%   54.54µ ± 1%  -1.30% (p=0.000 n=20)
ParseMediaTypeBogus-8   3.551µ ± 0%   3.427µ ± 0%  -3.48% (p=0.000 n=20)
geomean                 14.01µ        13.67µ       -2.39%

                      │     old      │                 new                 │
                      │     B/op     │     B/op      vs base               │
ParseMediaType-8        38.48Ki ± 0%   37.38Ki ± 0%  -2.85% (p=0.000 n=20)
ParseMediaTypeBogus-8   2.531Ki ± 0%   2.469Ki ± 0%  -2.47% (p=0.000 n=20)
geomean                 9.869Ki        9.606Ki       -2.66%

                      │    old     │                new                 │
                      │ allocs/op  │ allocs/op   vs base                │
ParseMediaType-8        457.0 ± 0%   425.0 ± 0%   -7.00% (p=0.000 n=20)
ParseMediaTypeBogus-8   25.00 ± 0%   21.00 ± 0%  -16.00% (p=0.000 n=20)
geomean                 106.9        94.47       -11.62%

Change-Id: I51198b40396afa51531794a57c50aa88975eae1d
GitHub-Last-Rev: c44e2a2
GitHub-Pull-Request: golang#75565
Reviewed-on: https://go-review.googlesource.com/c/go/+/705715
Reviewed-by: Emmanuel Odeke <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Sean Liao <[email protected]>
Reviewed-by: Damien Neil <[email protected]>
Auto-Submit: Emmanuel Odeke <[email protected]>
Remove redundant "type:" prefix check on symbol names in isFixedLoad,
also refactor some duplicate code into methods.

Change-Id: I8358422596eea8c39d1a30a554bd0aae8b570038
Reviewed-on: https://go-review.googlesource.com/c/go/+/701275
Reviewed-by: Keith Randall <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Auto-Submit: Keith Randall <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
While here, reorder Float32ConstantStore/Float64ConstantStore for
consistency.

Change-Id: Ic1b3e9f9474965d15bc94518d78d1a4a7bda93f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/703756
Reviewed-by: Keith Randall <[email protected]>
Auto-Submit: Keith Randall <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
Auto-Submit: Joel Sing <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64le_power10
Change-Id: Ifd7861488b1b47a5d30163552b51838f2bef7248
Reviewed-on: https://go-review.googlesource.com/c/go/+/706395
Reviewed-by: Carlos Amedee <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Auto-Submit: Keith Randall <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
The library entry point for loong64 is agnostic to the OS, so move it to
asm_loong64.s. This is similar to what we do for other architectures.

Cq-Include-Trybots: luci.golang.try:gotip-linux-loong64
Change-Id: I6915eb76d3ea72a779e05e78d85f24793169c61f
Reviewed-on: https://go-review.googlesource.com/c/go/+/706416
Reviewed-by: abner chenc <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
This test features a 5s timeout, which is far too close
to the natural variance in scheduling on an overloaded
CI builder machine to make a reliable test. Skipping.

Updates golang#72104

Change-Id: I52133a2d101808c923e316e0c7fdce9edbb31b10
Reviewed-on: https://go-review.googlesource.com/c/go/+/708075
Auto-Submit: Alan Donovan <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Michael Matloob <[email protected]>
Reviewed-by: Michael Matloob <[email protected]>
…erFunc

Fixes golang#75685

Change-Id: I5592becfde6aaca3d7f0e2f09bc7a9785228523e
GitHub-Last-Rev: 0ff7bd3
GitHub-Pull-Request: golang#75687
Reviewed-on: https://go-review.googlesource.com/c/go/+/708275
Reviewed-by: Alan Donovan <[email protected]>
Auto-Submit: Alan Donovan <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Damien Neil <[email protected]>
Auto-Submit: Sean Liao <[email protected]>
Reviewed-by: Damien Neil <[email protected]>
Reviewed-by: Sean Liao <[email protected]>
(addressing comment from review of CL 704737)

Change-Id: I483dea046f664035e79c51729203c9a9ff0cbc59
Reviewed-on: https://go-review.googlesource.com/c/go/+/708299
Auto-Submit: Alan Donovan <[email protected]>
Reviewed-by: Robert Griesemer <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
@austinderek austinderek force-pushed the master branch 27 times, most recently from 4c0fd3a to 5bf50a0 Compare October 7, 2025 13:10
@austinderek austinderek closed this Oct 7, 2025
@austinderek austinderek deleted the feat-template-errors-new branch October 7, 2025 13:10
Copy link

staging bot commented Oct 7, 2025

HackerOne Code Security Review

🟢 Scan Complete: 44 Issue(s)
🟠 Validation Complete: One or more Issues looked potentially actionable, so this was escalated to our network of engineers for manual review. Once this is complete you'll see an update posted.

Here's how the code changes were interpreted and info about the tools used for scanning.

📖 Summary of Changes The changes across multiple template-related Go files involve systematically replacing `fmt.Errorf()` with `errors.New()` for creating simple, static error messages. This modification simplifies error generation in template parsing and function handling, primarily in the `src/html/template` and `src/text/template` packages, with a focus on more direct error message creation.
File Summary
src/html/template/template.go The changes include replacing some fmt.Errorf() calls with errors.New(), specifically in the checkCanParse() method and parseFiles() function. The code now uses the errors package for creating simple error messages instead of formatting them.
src/text/template/funcs.go The changes involve replacing some direct error creation with errors.New() instead of fmt.Errorf() in several error-generating functions, such as indexArg(), index(), slice(), length(), and call(). This simplifies error generation for specific, static error messages.
src/text/template/helper.go The primary change is replacing fmt.Errorf(&quot;template: no files named in call to ParseFiles&quot;) with errors.New(&quot;template: no files named in call to ParseFiles&quot;), and adding an errors import to the import block.
ℹ️ Issues Detected

NOTE: These may not require action!

Below are unvalidated results from the Analysis Tools that ran during the latest scan for transparency. We investigate each of these for accuracy and relevance before surfacing them as a potential problem.

How will I know if something is a problem?
When validation completes, any concerns that warrant attention prior to merge will be posted as inline comments. These will show up in 2 ways:

  • Expert review (most cases): Issues will be posted by experts who manually reviewed and validated them. These are real HackerOne engineers (not bots) reviewing through an integrated IDE-like tool. You can communicate with them like any other reviewer. They'll stay assigned and get notified with commit & comment updates.
  • Automatically: In cases where our validation checks have highest confidence the problem is legitimate and urgent. These will include a description of contextual reasoning why & actionable next steps.
File & Line Issue
src/cmd/compile/internal/ssa/rewriteWasm.go Line 3204 The code has removed a dependency on internal/buildcfg and also removed conditional code paths that were using buildcfg.GOWASM.SignExt. The sign extension operations now always use the direct WebAssembly instructions (I64Extend8S, I64Extend16S, I64Extend32S) without checking if they're supported by the target. This could potentially cause compatibility issues if these instructions aren't available in all WebAssembly environments the code is targeting.
src/mime/mediatype.go Line 345 The percentHexUnescape function has been modified to return a boolean instead of an error. This change could lead to silent failures where previously errors would be reported. The function now returns (string, bool) instead of (string, error), and error cases that previously returned detailed error messages now just return false without any context about what went wrong.
src/debug/elf/file.go Line 1834 The new putUint function has a potential integer overflow vulnerability. In line 1834, the condition math.MaxUint64-start &lt; length is intended to prevent integer overflow when checking bounds, but it doesn't fully protect against all overflow cases. The function also doesn't check for overflow when adding sym+ae in lines 1849 and 1855, which could lead to incorrect values being written if the sum exceeds the maximum value for the respective data type.
src/internal/poll/fd_windows.go Line 266 The code introduces runtime.Pinner to pin memory during I/O operations, but there's a potential memory safety issue in the pin/unpin pattern. In the execIO function, the operation object 'o' is pinned but then put back into the operationPool before the deferred unpinning happens. This could lead to a situation where memory is unpinned after it's already been reused by another goroutine, causing memory corruption.
src/cmd/link/internal/ld/macho.go Line 109 These changes add two new constants for Mach-O ARM64 relocation types. The additions are just constant definitions and don't introduce any security vulnerabilities. The constants MACHO_ARM64_RELOC_SUBTRACTOR and MACHO_ARM64_RELOC_POINTER_TO_GOT are standard relocation types used in the Mach-O binary format for ARM64 architecture.
src/runtime/conv_wasm_test.go Line 26 The changes to the test expectations for float-to-integer conversions indicate that the behavior of these conversions has changed. If this is due to a change in the runtime implementation (removal of wasmTruncS/wasmTruncU functions in sys_wasm.s), it could affect the behavior of applications that rely on specific overflow/underflow handling for float-to-integer conversions in WebAssembly.
src/cmd/link/internal/ld/symtab.go Line 648 The change on line 648 modifies how the cutab slice is handled in the moduledata. The original code used sliceSym which would set the length and capacity to the full size of the symbol. The new code explicitly divides the size by 4, which suggests the cutab contains 4-byte elements. If the cutab's size is not actually a multiple of 4, this could lead to incorrect memory access or buffer overflows when the runtime uses this data.
src/testing/synctest/synctest.go Line 150 The error message in the test example was corrected from 'before context is canceled: AfterFunc not called' to 'after context is canceled: AfterFunc not called'. This is a documentation fix that improves accuracy but doesn't introduce security vulnerabilities.
src/runtime/asm_ppc64x.s Line 39 The added code introduces a new function _rt0_ppc64x_lib that handles library initialization. The function uses a hardcoded stack size of 8192KB (line 39) without validation. While this is common in low-level runtime code, it's worth noting that this fixed allocation might be excessive for some environments or insufficient for others. Consider whether this size should be configurable or determined dynamically based on the environment.
src/cmd/cgo/internal/testcshared/cshared_test.go Line 276 The change removes _cgo_dummy_export from the Windows DLL export list. This is a security improvement as it reduces the attack surface by removing an unnecessary exported symbol. The code now correctly handles the case where there are no exported symbols by using cmp.Or(exportedSymbols, 1) to ensure at least one symbol is expected.
src/cmd/link/internal/loader/loader.go Line 1115 The new ForAllCgoExportStatic function uses the iter package to create an iterator over symbols marked with the "cgo_export_static" compiler directive. This introduces a potential security issue if the caller doesn't properly handle early termination of the iteration. If the yield function returns false to stop iteration, but the caller doesn't check for this condition, it could lead to incomplete processing of security-critical symbols. This is especially concerning for CGO exports which often involve interactions between Go and C code, a common source of security vulnerabilities.
src/crypto/internal/fips140/mlkem/mlkem768.go Line 175 The added fipsSelfTest() function calls on lines 175, 189, 342, 354, and 460 are being invoked without checking their return values. If this function is meant to perform security validation and can fail, not handling potential errors could lead to the system operating in an insecure state. The code should either check the return value or ensure the function panics on failure.
src/runtime/export_test.go Line 1940 The added lines expose a debug flag DebugDecorateMappings and a function SetVMANameSupported() to the test package. While these additions themselves don't introduce security vulnerabilities, exposing internal debug flags to test code could potentially be misused if the test package is imported by non-test code in production. However, this is a standard pattern in Go for testing and the risk is minimal since these are only exported for testing purposes.
src/crypto/internal/fips140/mlkem/cast.go Line 15 The change introduces a potential race condition. The fipsSelfTest function is defined but never called in the init function. This means the CAST self-test for ML-KEM-768 might never run, which could lead to using cryptographic functionality without proper validation in FIPS mode.
src/encoding/xml/read.go Line 261 The code changes replace direct type assertions with reflect.TypeAssert, but the implementation is vulnerable to type confusion. The new code checks if val.CanInterface() but doesn't verify the type before attempting the type assertion with reflect.TypeAssert. If the value doesn't implement the expected interface, the code will panic at runtime rather than gracefully handling the error.
src/cmd/link/internal/ld/symtab.go Line 657 On line 657, the code changes from using a custom slice function with explicit size to using sliceSym. This change appears to be safer as it uses the actual symbol size rather than a potentially incorrect manual calculation, reducing the risk of buffer overflows.
src/cmd/cgo/out.go Line 1009 The code removes the __declspec(dllexport) attribute from exported functions in Windows builds. This could prevent proper symbol exporting when building DLLs on Windows, potentially making exported functions inaccessible to external code that tries to dynamically link against the library.
src/cmd/link/internal/ld/pe.go Line 1788 The function peCreateExportFile writes a .def file to a location specified by the *flagTmpdir flag without proper path validation or sanitization. This could potentially lead to path traversal issues if the flagTmpdir value contains malicious path components. Additionally, the file is created with 0666 permissions, making it world-readable and writable, which could be a security concern in shared environments.
src/cmd/compile/internal/ssa/_gen/Wasm.rules Line 58 The changes simplify the sign extension operations by removing conditional checks for the buildcfg.GOWASM.SignExt feature flag. The code now directly uses WebAssembly's native sign extension instructions (I64Extend32S, I64Extend8S, and I64Extend16S) instead of conditionally using them or falling back to a more complex implementation using shifts. This change doesn't introduce security vulnerabilities but does change the compiler's behavior to always use these native instructions.
src/cmd/link/dwarf_test.go Line 367 The change adds a check for DWARF support on the current platform before running the TestFlagW test. This is a positive security change that prevents the test from running on unsupported platforms, avoiding potential test failures or undefined behavior. No security vulnerabilities are introduced by this change.
src/crypto/internal/fips140/mlkem/mlkem1024.go Line 116 The added fipsSelfTest() calls in multiple functions (generateKey1024, GenerateKeyInternal1024, encapsulate, EncapsulateInternal, Decapsulate) could potentially introduce a security issue if the self-test fails silently. The code doesn't show how errors from fipsSelfTest() are handled, which might allow cryptographic operations to proceed even when the self-test fails. This could lead to using a cryptographic implementation that doesn't meet FIPS requirements.
src/crypto/internal/fips140test/entropy_test.go Line 40 The test file contains a potential security issue in the TestEntropySamples function. When flagEntropySamples is set, it writes entropy samples to files with 0644 permissions. Writing entropy data to disk with world-readable permissions could expose sensitive randomness patterns to other users on the system, potentially weakening cryptographic operations if an attacker can analyze these patterns.
src/cmd/compile/internal/ssa/rewrite.go Line 2062 The code changes modify how type information is accessed from symbols. Instead of directly accessing lsym.Extra and checking if it's a *obj.TypeInfo or *obj.ItabInfo, the code now uses helper methods lsym.TypeInfo() and lsym.ItabInfo(). This is a safer approach as it encapsulates the type checking and casting logic, but doesn't introduce any security vulnerabilities.
src/cmd/link/internal/ld/xcoff.go Line 1782 The change replaces a manual iteration over all symbols to check for AttrCgoExport with a call to ldr.ForAllCgoExportStatic(). This is a safer approach as it uses a dedicated method to iterate over the specific symbols needed, rather than manually filtering. However, the new code doesn't check if the returned symbol is valid before using it, which could potentially lead to issues if the method returns invalid symbols.
src/runtime/runtime1.go Line 405 The function parsedebugvars() has been replaced with parseRuntimeDebugVars(godebug string), which now takes a string parameter instead of reading from the environment directly. This change removes the direct environment variable access from this function, which is a security improvement as it allows for more controlled access to environment variables. The caller can now validate or sanitize the input before passing it to this function.
🧰 Analysis tools

⏱️ Latest scan covered changes up to commit a0d7e69 (latest)

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.