| Age | Commit message (Collapse) | Author |
|
When a map element or key type is 2GB or larger, the compiler crashed
with "internal compiler error: map elem too big" in reflectdata.ZeroAddr.
Add a size check in types.CalcSize for TMAP, similar to the existing
check for channel element types, so that oversized map elements are
reported as a normal error before reaching ZeroAddr.
Fixes #78355
Change-Id: I281a5f0ec7dda6dac084787859156d4409dc860c
Reviewed-on: https://go-review.googlesource.com/c/go/+/760600
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
Change-Id: I27696b1a5fa0593d9f36743efa3559a36d23ec4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/760844
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
|
|
- fix a bug where it wouldn't recognize 1<<63 as a power of two
- remove the IsSigned check; there is no such thing as a signed Mul
If the rule works for signed numbers it works for unsigned ones too.
Even if the intermediary steps makes no sense, it ends up wrapping
the right way around in the end.
Change-Id: I86182762aec5eff784e2d9bc49ee028825fb9ea0
Reviewed-on: https://go-review.googlesource.com/c/go/+/760843
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
|
|
Currently, all Op implementations on loong64 do not modify the FCSR
(floating point control status register), but users can modify the
FCSR for special floating point computing needs.
FCSR is also saved and restored in the fpu context of the Linux kernel [1].
[1]: https://github.com/torvalds/linux/blob/master/arch/loongarch/kernel/fpu.S#L565C1-L566C1
Change-Id: I776e72dfcc1f027bfe8d22aa2eae453100a6ee1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/761720
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
(I copied Ilya Tocar's CL 27656 and heavily modified it.)
This adds an optimization that moves loop invariant computations
out of the loop. For example:
a:= ...
for ... {
b:= a + 15
// uses of b
}
Turns into
a:= ...
b:= a + 15
for ... {
// uses of b
}
Change-Id: I36c8c7e2b3bc1c5e6b4b293bed3a76dc20d6c825
Reviewed-on: https://go-review.googlesource.com/c/go/+/697235
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
|
|
consumeComment builds the comment string by repeated string
concatenation inside a loop. Each concatenation copies the
entire string built so far, making the function O(n^2) in the
depth of nested comments.
Replace the concatenation with a strings.Builder, which
amortizes allocation by doubling its internal buffer. This
reduces consumeComment from O(n^2) to O(n).
This is the same bug class as the consumeDomainLiteral fix
in CVE-2025-61725.
Benchmark results (benchstat, 8 runs):
name old time/op new time/op delta
ConsumeComment/depth10 2.481us 1.838us -25.92%
ConsumeComment/depth100 86.58us 6.498us -92.50%
ConsumeComment/depth1000 7.963ms 52.82us -99.34%
ConsumeComment/depth10000 897.8ms 521.3us -99.94%
The quadratic cost becomes visible at depth 100 and dominant
by depth 1000. At depth 10000, the fix is roughly 1700x
faster.
Change-Id: I3c927f02646fcab7bab167cb82fd46d3327d6d34
GitHub-Last-Rev: 7742dad716ee371766543f88e82bd163bd9d7ac2
GitHub-Pull-Request: golang/go#78393
Reviewed-on: https://go-review.googlesource.com/c/go/+/759940
Reviewed-by: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
|
|
Change-Id: Iac9428fe8d2fb3e6fde30940470bf5d3ac9751cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/763141
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
|
|
Change-Id: I32af8f18da6c9c95d6fe6189d2f6735868667b3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/763120
Auto-Submit: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
Change-Id: Ic97f661c68180ff7adb9976fcc61279e1e1f04a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/760842
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
On amd64 along:
if b { x += 1 } => x += b
We can also implement constants 2 4 and 8:
if b { x += 2 } => x += b * 2
This compiles to a displacement LEA.
Change-Id: Ib00fcc5059acb0ebb346e056c4a656f164cc63df
Reviewed-on: https://go-review.googlesource.com/c/go/+/760841
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
|
|
Fixes #51714
Change-Id: I0619b1ca6715bed85ccc066a83a449f66a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/762660
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
|
|
The nsec field of timespec is a C long even when using
64bits time on 32bits systems.
This is because by timespec API if nsec never holds more than a
second worth of nanoseconds.
If it would theses would increment the sec field while the nsec
field would get the amount of nanoseconds modulus a second.
Fixes #77934
Change-Id: I9803998ba70123eb3b226379bd72b11cae972c38
Reviewed-on: https://go-review.googlesource.com/c/go/+/751341
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
Change-Id: Ib03f65992b065e169fa6ccd08664336bec559c1d
GitHub-Last-Rev: bd597d4325c713c53a9f22cb93892d90f393c6ac
GitHub-Pull-Request: golang/go#78527
Reviewed-on: https://go-review.googlesource.com/c/go/+/762700
Reviewed-by: Nicholas Husin <nsh@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
|
|
This overhauls writeMultiple to reduce allocations:
- return early if called with a count of 0 rather than allocating a buffer
- if writing one byte, which happens when padding, try io.ByteWriter
- try io.StringWriter
- fallback to io.Writer as currently done
Unlike what is suggested in #71465 I did not used io.WriteString
to avoid a regression where we would allocate the byte slice
once per iteration of count.
goos: linux
goarch: amd64
pkg: math/big
cpu: AMD Ryzen 5 3600 6-Core Processor
│ /tmp/old │ /tmp/new │
│ sec/op │ sec/op vs base │
Format-12 70.45µ ± 1% 63.55µ ± 2% -9.80% (p=0.000 n=10)
│ /tmp/old │ /tmp/new │
│ B/op │ B/op vs base │
Format-12 14.73Ki ± 0% 10.96Ki ± 0% -25.58% (p=0.000 n=10)
│ /tmp/old │ /tmp/new │
│ allocs/op │ allocs/op vs base │
Format-12 1098.0 ± 0% 649.0 ± 0% -40.89% (p=0.000 n=10)
Fixes #71465
Change-Id: I44565c540b2d73c8737ac9733687141b645d9856
Reviewed-on: https://go-review.googlesource.com/c/go/+/645215
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
|
|
Fixes #78528
Change-Id: I8979a310dbf94b9710d3e8428480cb49a7308294
GitHub-Last-Rev: 3d7f5ef1491f15923add6ef556e387eb8d49bf3b
GitHub-Pull-Request: golang/go#78518
Reviewed-on: https://go-review.googlesource.com/c/go/+/762480
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
|
|
tempDirWithUnixSocket used os.MkdirTemp("", ""), while other paths in
root consistency tests use t.TempDir().
If GOTMPDIR and the system temp dir are on different filesystems (such
as during abuild), TestRootConsistencyRename and TestRootConsistencyLink
may produce EXDEV.
Fixes #78063
Change-Id: Ib81abec0876babf0cc0e2d9e53e34f051ddfbbc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/754102
Auto-Submit: Sean Liao <sean@liao.dev>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
|
|
Adds a fuzz test for quoteArgs and fixes the bugs it found:
handling of empty strings and strings containing "&" or "$".
This is a copy of a similar change submitted to rsc.io/script:
https://github.com/rsc/script/pull/10
Change-Id: I76e7fc89475e1c4e415f45f2c7ac4a87a7a659e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/566316
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
|
|
Refactor the DWARF variable generation in the compiler:
1. Replace the intermediate []byte location list encoding with a
structured LocListEntry type. The old code packed SSA block/value
IDs into pointer-sized integers, wrote them alongside DWARF4-format
length-prefixed expressions, then re-read and decoded everything
during final encoding. The new approach stores entries as
{StartBlock, StartValue, EndBlock, EndValue, Expr} structs that
PutLocationListDwarf4/5 directly encode into the appropriate format.
This eliminates encodeValue, decodeValue, appendPtr, writePtr,
readPtr, and SetupLocList, and removes the DWARF4 re-encoding in
PutLocationListDwarf5.
2. Unify createDwarfVars into a single processing loop. The old code
had three mutually exclusive paths (createSimpleVars, createABIVars,
createComplexVars) selected by build mode, followed by a separate
conservative-var loop. The new code uses one loop that tries
createComplexVar first (when SSA debug info is available), then
falls back to createSimpleVar. This removes createSimpleVars,
createABIVars, and createComplexVars.
3. Extract createConservativeVar and shouldEmitDwarfVar as named
functions, consolidating inline code and scattered filtering logic.
4. Fix createHeapDerefLocationList to return []LocListEntry instead
of raw bytes, consistent with the new representation.
Change-Id: If6fb755c22e398d7615dccaf33b1367828e6c47e
Reviewed-on: https://go-review.googlesource.com/c/go/+/750920
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
|
|
Logical ops on uint8/uint16 (AND/OR/XOR) with constants sometimes
materialized the mask via MOVD (often as a negative immediate), even
when the value fit in the UI-immediate range. This prevented the backend
from selecting andi. / ori / xori forms.
This CL makes:
UI-immediate truncation is performed only at the use-site of
logical-immediate ops, and only when the constant does not fit in the
8- or 16-bit unsigned domain (m != uint8(m) / m != uint16(m)).
This avoids negative-mask materialization and enables correct emission of
UI-form logical instructions. Arithmetic SI-immediate instructions (addi, subfic, etc.) and other
use-patterns are unchanged.
Codegen tests are added to ensure the expected andi./ori/xori
patterns appear and that MOVD is not emitted for valid 8/16-bit masks.
Change-Id: I9fcdf4498c4e984c7587814fb9019a75865c4a0d
Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64_power10,gotip-linux-ppc64_power8,gotip-linux-ppc64le_power8,gotip-linux-ppc64le_power9,gotip-linux-ppc64le_power10
Reviewed-on: https://go-review.googlesource.com/c/go/+/704015
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Paul Murphy <paumurph@redhat.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
|
|
Add support for the PAUSE instruction provided by the Zihintpause
extension.
Change-Id: If06cce4ca57137275f567b5fe29ef85517f381ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/710495
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
Switch statement containing integer constant cases and case bodies just
returning a constant should be optimizable to a simpler and faster table
lookup instead of a jump table.
That is, a switch like this:
switch x {
case 0: return 10
case 1: return 20
case 2: return 30
case 3: return 40
default: return -1
}
Could be optimized to this:
var table = [4]int{10, 20, 30, 40}
if uint(x) < 4 { return table[x] }
return -1
The resulting code is smaller and faster, especially on platforms where
jump tables are not supported.
goos: windows
goarch: arm64
pkg: cmd/compile/internal/test
│ .\old.txt │ .\new.txt │
│ sec/op │ sec/op vs base │
SwitchLookup8Predictable-12 2.708n ± 6% 2.249n ± 5% -16.97% (p=0.000 n=10)
SwitchLookup8Unpredictable-12 8.758n ± 7% 3.272n ± 4% -62.65% (p=0.000 n=10)
SwitchLookup32Predictable-12 2.672n ± 5% 2.373n ± 6% -11.21% (p=0.000 n=10)
SwitchLookup32Unpredictable-12 9.372n ± 7% 3.385n ± 6% -63.89% (p=0.000 n=10)
geomean 4.937n 2.772n -43.84%
Fixes #78203
Change-Id: I74fa3d77ef618412951b2e5c3cb6ebc760ce4ff1
Reviewed-on: https://go-review.googlesource.com/c/go/+/756340
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
This change slightly extends expression traversal to recognize
explicit instantiation of generic methods. The relevant MethodVal
and MethodExpr snippets are extracted into helper functions, since
they are needed in two places.
Change-Id: I85d49d89f2422fa4c2d09de28fb6552f171a2a1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/762560
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
|
|
RDNSequence.String builds its result using repeated s += ... inside
nested loops, leading to O(N²) time and memory complexity.
A certificate with many Subject or Issuer RDN entries can therefore
cause excessive CPU and memory usage when String is called.
Switch to strings.Builder to construct the output, reducing complexity
to O(N) without changing behavior.
This follows the same approach used to fix CVE-2025-61729
(HostnameError.Error), which addressed the same quadratic concatenation
pattern.
Change-Id: Id44303b5732081de9f01d186bc2b8ac66349a650
GitHub-Last-Rev: b0706c20655d1a263c3a989b76c0c25796c900df
GitHub-Pull-Request: golang/go#78265
Reviewed-on: https://go-review.googlesource.com/c/go/+/757680
Reviewed-by: Navtej Kathuria US <nkathuria@nvidia.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mateusz Poliwczak <mpoliwczak34@gmail.com>
|
|
Clarify that on Windows, Dir("C:") returns "C:." (the current directory
on drive C) rather than a root path. This is because Clean("") returns
"." and Dir prepends the volume name.
Fixes #77314
Change-Id: Idbc8ef5a4905e8587268428503a98a28c8c2f6e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/740902
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Olivier Mengué <olivier.mengue@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
|
|
"go generate" on this package seems to generate a diff.
I have no idea whether this diff is reasonable or not.
It looks kinda weird, but maybe? Or perhaps something is wrong with
../mkcnames.go.
Change-Id: I3474bab3f6880ffc24c1cf6ec11958a1c9467909
Reviewed-on: https://go-review.googlesource.com/c/go/+/761680
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
|
|
If the bool comes from a local operation this is foldable into the comparison.
if a == b {
} else {
x++
}
becomes:
x += !(a == b)
becomes:
x += a != b
If the bool is passed in or loaded rather than being locally computed
this adds an extra XOR ^1 to invert it.
But at worst it should make the math equal to the compute + CMP + CMOV
which is a tie on modern CPUs which can execute CMOV on all int ALUs
and a win on the cheaper or older ones which can't.
Change-Id: Idd2566c7a3826ec432ebfbba7b3898aa0db4b812
Reviewed-on: https://go-review.googlesource.com/c/go/+/760922
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
|
|
Emitting wrapper functions for generic methods is tricky for 2 reasons:
1. Existing downstream machinery expects that it can make certain
assumptions about a method if it sees a wrapper function. We
may violate those assumptions with generic method wrappers.
2. Signatures for generic methods are generic and hence cannot be
encoded using w.typ.
This has the slight downside of not using a statically computed
wrapper for generic methods and instead dynamically computing the
dictionary pointer. Thus, we miss out on a performance optimization
for generic methods for now. Code that does not use generic methods
is unaffected.
Change-Id: I72c626ef0f807c0cb54d8cf040250de8177303cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/762382
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
|
|
Change-Id: I9846b8086bacbc69e438a8e39e3e26c46316fb08
Reviewed-on: https://go-review.googlesource.com/c/go/+/762022
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
|
|
When a writer goes to encode use of a type parameter, it only records
an index because the writer knows all of the type parameters in scope
for that object.
The writer orders the type parameteres as implicits first, then
receivers, then explicits actually on the object. Note that receivers
*are* explicit type arguments, they're just inherited from the type.
For instance, given:
func (T[P]) m[Q, R any]()
This has:
- 0 implicits
- 1 receiver
- 2 explicits
With this ordering, P is at 0, Q is at 1, and R is at 2. In contrast,
inspecting TypeParam.index for Q yields 0, and for R yields 1; hence
the offset is needed.
Change-Id: If12f342e109fbc5935ba278f574ac2809c889335
Reviewed-on: https://go-review.googlesource.com/c/go/+/762021
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
Change-Id: I7a66fba400a743f4ef2fb989cd8e74e955e22b0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/762020
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
|
|
Hasher is the standard interface for expressing custom hash
functions and equivalence relations for arbitrary data types.
This allows them to be used in hash-based collection types
such as a hash table (CL 612217) or a Bloom filter (CL 740440).
The ComparableHasher type is an implementation of the Hasher
interface for comparable values that is consistent with their
usual equivalence relation (==).
Fixes #70471
Change-Id: Iaa42eb7017d9c4dab487ad6c842c68a81fa7d28a
Reviewed-on: https://go-review.googlesource.com/c/go/+/657296
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
TryBot-Bypass: Alan Donovan <adonovan@google.com>
|
|
This is inspired by CL 724560 by Bobby Powers, particularly their great
commit message.
When using address sanitizer with leak detection, sysReserve registers
memory regions with LSAN via lsanregisterrootregion. However, several
code paths release this memory using sysFreeOS without first
unregistering from LSAN. This leaves LSAN with stale root region entries
pointing to memory that has been unmapped and may be reallocated for
other purposes.
This bug was latent until glibc 2.42, which changed pthread stack guard
pages from mprotect(PROT_NONE) to madvise(MADV_GUARD_INSTALL). The
difference matters because LSAN filters root region scanning by
intersecting registered regions with readable mappings from
/proc/self/maps:
- mprotect(PROT_NONE) splits the VMA, creating a separate entry with
---p permissions. LSAN's IsReadable() check excludes it from scanning.
- MADV_GUARD_INSTALL operates at the page table level without modifying
the VMA. The region still appears as rw-p in /proc/self/maps, so LSAN
includes it in the scan and crashes with SIGSEGV when accessing the
guard pages.
Address this by adding sysUnreserve to undo sysReserve. sysUnreserve
unregisters the region from LSAN and frees the mapping.
With the addition of sysUnreserve, we have complete coverage of LSAN
unregister in the mem.go abstract: sysFree unregisters Ready memory.
sysUnreserve unregisters Reserved memory. And there is no way to free
Prepared memory at all (it must transition to Ready or Reserved first).
The implementation of lsanunregisterrootregion [1] finds the region by
exact match of start and end address. It therefore does not support
splitting a region, and we must extend this requirement to sysUnreserve
and sysFree. I am not completely confident that we always pass the full
region to sysFree, but LSAN aborts if it can't find the region, so we
must not be blatantly violating this.
sysReserveAligned does need to unreserve a subset of a region, so it
cannot use sysUnreserve directly. Rather than breaking the mem.go
abstract, move sysReserveAligned into mem.go, adding it to the
abstraction.
We should not have any calls to sysFreeOS outside of the mem.go
abstraction. That is now true with this CL.
Fixes #74476.
[1] https://github.com/llvm/llvm-project/blob/3e3e362648fa062038b90ccc21f46a09d6902288/compiler-rt/lib/lsan/lsan_common.cpp#L1157
Change-Id: I8c46a62154b2f23456ffd5086a7b91156a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/762381
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
sysFree decrements mappedReady since CL 393402, meaning it can only be
used on Ready memory, not any memory as stated.
The example uses are not relevant as those cases would not necessarily
be Ready memory. The no-op note is meant to be relevant to
sysReserveAligned, but that doesn't use sysFree anyway.
Change-Id: I3aeb0e703b0a57202a01317e0904cd966a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/762380
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
|
|
For Go symbols accessed from other package via linkname or
assembly, we have an export linkname from the definition side. We
currently don't always have the linkname directive for assembly
functions, for which external accesses are allowed. We may want
to tighten up the restriction. So add export linknames for the ones
that are needed.
Change-Id: If664634c81580edd49086d916024f23f86871092
Reviewed-on: https://go-review.googlesource.com/c/go/+/749981
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
|
|
For the compiler, we already pass -std when compiling the standard
library. Do the same for the assembler. So the assembler and the
linker can tell which objects are in the standard library.
Change-Id: I35d28a4c72d32c344eda37a3ff407ea525ee5cea
Reviewed-on: https://go-review.googlesource.com/c/go/+/761200
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
|
|
libInit runs before rt0_go, which is where TLS setup occurs. Thus the
contents of the TLS may not be defined, so the g lookup in asmcgocall is
not safe.
Concretely, android-386 c-shared builds crash without this change
because asmcgocall reads an invalid non-zero g from the TLS.
Move libInit to a file limited to GOARCH that support c-archive or
c-shared so that only those require asmcgocall_no_g. In addition,
loong64 and s390x need asmcgocall_no_g implementations.
Fixes #78480.
Cq-Include-Trybots: luci.golang.try:gotip-linux-loong64,gotip-linux-s390x
Change-Id: I175e6d020339af89c9b576535d79c1e76a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/761541
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
|
|
Change-Id: Icc89533e4cfc737bfee8b0c7a72006bdc79746c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/762280
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
This CL reverts the purego implementation added in CL 468795
and folds the runtime variant back into the main file.
Purego means "no assembly"; it does not mean "no linkname".
Henceforth this package will once again call runtime.memhash
unconditionally.
This was not a clean revert as there were a number of CLs since.
The motivation for this change is to avoid the maphash -> crypto/rand
dependency; see discussion on CL 657297.
Change-Id: I54ce223c5b484710ce303cdec20049146df3f8bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/761260
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
|
|
Fix godoc for package io/fs functions where 'fs' is mentioned instead of
the 'fsys' argument. This allows to more clearly distinguish references
to the methods of that argument from functions of the io/fs package.
Change-Id: I18674940e59dcf4501f46ee48f94fc58948df28c
Reviewed-on: https://go-review.googlesource.com/c/go/+/755480
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
|
|
We have not yet added the decoding on the reader side.
Change-Id: Ic7f8dc51b6b9a2c214b402b1314ee84c0085c16a
Reviewed-on: https://go-review.googlesource.com/c/go/+/761983
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
|
|
This splits objTypeParams into objTypeParams and objRecvTypeParams. The
type parameters on a generic method and its receiver need to be reported
separately to the reader.
Change-Id: If9eb93ca66a5a5e4bdce71364627ff4bee110311
Reviewed-on: https://go-review.googlesource.com/c/go/+/761981
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
|
|
Fixes #78483.
For #78314.
Change-Id: If83983c0bf79840aa02dc0d2fa8945f5e8b4e969
Reviewed-on: https://go-review.googlesource.com/c/go/+/761682
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
|
|
Often we want to run _mkmalloc using a different toolchain. The
previous module path runtime/_mkmalloc would produce an ambiguous import
path error because the directory runtime/_mkmalloc exists in a Go 1.26+
toolchain. Rename the module to avoid the conflict.
Change-Id: Id73a3ca102081d8b51da58879aee851b6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/761880
Reviewed-by: Michael Matloob <matloob@google.com>
Auto-Submit: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
When not in race mode, we redirect the sync/atomic functions to
internal/runtime/atomic with assembly stubs in the sync/atomic
package. Access from assembly is similar to linkname, so they need
export linknames from internal/runtime/atomic. We currently have
export linknames only for the Go functions, which varies from
architecture to architecture. This CL adds export linknames to
assembly functions as well, so they are same on all architectures.
Linknames on assembly functions don't hurt. Also, we may restrict
linkname access to assembly symbols without a push or export
linkname later. This CL prepares for that.
Change-Id: Ic6167a2f6610b9b1b1193e2ea86095ab7506b282
Reviewed-on: https://go-review.googlesource.com/c/go/+/749945
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
Change-Id: I1f2fc247cdf979a40cbd48b4feab449c0ff6182e
Reviewed-on: https://go-review.googlesource.com/c/go/+/761860
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
|
|
Add retpoline and tls_g symbols as the assembler generates direct
reference to them.
Change-Id: I569eab6d81798866263da9240d702139d3567d57
Reviewed-on: https://go-review.googlesource.com/c/go/+/761464
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
|
|
In runtime/secret's TestCore, it copies some files from the
runtime/secret package to a test main package, including assembly
files. The assembly function references a stub function in Go,
which is also copied. Make it reference the copied one, not the
original one, to avoid cross-package assembly references.
We may want to rewrite the test to avoid copy, e.g. including the
test functions in the test binary itself and having the test
run itself in a subprocess. Leave that for later.
Change-Id: I5187edcc41d1d0469fc6b1b5f2acc60df37e5c1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/761520
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
|
|
When the linker sees two symbols with the same name, if both are
dupok, pick the one with larger size. If one is dupok, one is not,
pick the one that is not dupok, as "dupok" is sort of like weak
symbol in C terms.
Change-Id: I0a95d1ddfdd70ffb5ecc06645fb345591039af49
Reviewed-on: https://go-review.googlesource.com/c/go/+/749943
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|
|
In the standard library, there are a number of linknames, for
sharing symbols within the standard library. They are not supposed
to be accessed externally. But currently there is no good
mechanism to prevent that. In the linker we have a blocklist of
linknames, which forbids linkname references other than explicitly
allowed packages. The blocklist is manually maintained, requiring
periodic manual update.
To move away from that manually maintained blocklist, this CL
introduces a new directive, linknamestd, that marks a linkname
for use within the standard library only. The linker will allow
references within the standard library and forbid others.
For a proof of concept, runtime.coroswitch is removed from the
blocklist, and replaced with linknamestd. An external reference to
it is still disallowed by the linker, as tested with
cmd/link.TestCheckLinkname with testdata/linkname/coro.go.
Change-Id: I0d0f8746b8835d8cdcfc3ff835d22a551da5f038
Reviewed-on: https://go-review.googlesource.com/c/go/+/749942
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
|
|
The test was skipped when darwin/arm64 meant iOS, and our LLDB
runner could not handle signals. Now darwin/arm64 is macOS, it
works just fine.
Change-Id: I04b2b60046c6a0df01a5d5c23d7203d469af20de
Reviewed-on: https://go-review.googlesource.com/c/go/+/749941
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
|