aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
AgeCommit message (Collapse)Author
2025-09-29cmd/link: use a .def file to mark exported symbols on Windowsqmuntal
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 #30674 Fixes #56994 Change-Id: I22bd0aa079e2be4ae43b13d893f6b804eaeddabf Reviewed-on: https://go-review.googlesource.com/c/go/+/705776 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Than McIntosh <thanm@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-29runtime: jump instead of branch in netbsd/arm64 entry pointqmuntal
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-09-27all: fix typosAN Long
Change-Id: I290812905b6b5c52f289f7f8524f93aef19e6efe Reviewed-on: https://go-review.googlesource.com/c/go/+/706775 Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Sean Liao <sean@liao.dev>
2025-09-26runtime: use a smaller arena size on WasmCherry Mui
On Wasm, some programs have very small heap. Currently, we use 4 MB arena size (like all other 32-bit platforms). For a very small program, it needs to allocate one heap arena, 4 MB size at a 4 MB aligned address. So we'll need 8 MB of linear memory, whereas only a smaller portion is actually used by the program. On Wasm, samll programs are not uncommon (e.g. WASI plugins), and users are concerned about the memory usage. This CL switches to a smaller arena size, as well as a smaller page allocator chunk size (both are now 512 KB). So the heap will be grown in 512 KB granularity. For a helloworld program, it now uses less than 3 MB of linear memory, instead of 8 MB. Change-Id: Ibd66c1fa6e794a12c00906cbacc8f2e410f196c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/683296 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-26[dev.simd] simd, cmd/compile: add 128 bit select-from-pairDavid Chase
Using this name until a better one appears: x.Select128FromPair(3, 2, y) Includes test for constant and variable case. Checks for unexpected immediates (using the zeroing flag, which is not supported for this intrinsic) and panics. Change-Id: I9249475d6572968c127b4ee9e00328d717c07578 Reviewed-on: https://go-review.googlesource.com/c/go/+/705496 Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-26runtime: move TestReadMetricsSched to testprogMichael Anthony Knyszek
There are just too many flakes resulting from background pollution by the testing package and other tests. Run in a subprocess where at least the environment can be more tightly controlled. Fixes #75049. Change-Id: Iad59edaaf31268f1fcb77273f01317d963708fa6 Reviewed-on: https://go-review.googlesource.com/c/go/+/707155 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-09-26runtime: unify arm64 entry point codeqmuntal
There is a lot of duplication in how arm64 OSes handle entry points. Do as amd64, have all the logic in a common function. Cq-Include-Trybots: luci.golang.try:gotip-darwin-arm64-longtest,gotip-windows-arm64 Change-Id: I370c25c3c4b107b525aba14e9dcac34a02d9872e Reviewed-on: https://go-review.googlesource.com/c/go/+/706175 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2025-09-25runtime: use common library entry point on windows amd64/386qmuntal
Windows can reuse the common library entry point instead of implementing a its own version. Note that windows/arm64 already uses the common one. Change-Id: I1a27bbec04bfd1d58a136638bafcdc0583bd106f Reviewed-on: https://go-review.googlesource.com/c/go/+/706235 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-09-25std: remove unused declarationsAlan Donovan
One function was unused by mistake, and is now used as intended. Change-Id: I42ae7481c6f794b310bdac656ea525bd882f146e Reviewed-on: https://go-review.googlesource.com/c/go/+/706815 Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-25[dev.simd] all: merge master (d70ad4e) into dev.simdCherry Mui
Conflicts: - src/cmd/compile/internal/types2/stdlib_test.go - src/go/types/stdlib_test.go Merge List: + 2025-09-25 d70ad4e740 sync/atomic: correct Uintptr.Or return doc + 2025-09-25 d7abfe4f0d runtime: acquire/release C TSAN lock when calling cgo symbolizer/tracebacker + 2025-09-25 393d91aea0 cmd/fix: remove all functionality + 2025-09-25 6dceff8bad cmd/link: handle -w flag in external linking mode + 2025-09-25 76d088eb74 cmd/internal/obj/riscv: remove ACFLWSP/ACFSWSP and ACFLW/ACFSW + 2025-09-25 5225e9dc49 doc/next: document new image/jpeg DCT in release notes + 2025-09-25 81a83bba21 cmd: update x/tools@4df13e3 + 2025-09-25 6b32c613ca go/types: make typeset return an iterator + 2025-09-25 fbba930271 image/jpeg: replace fdct.go and idct.go with new implementation in dct.go + 2025-09-25 92e093467f image/jpeg: correct and test reference slowFDCT and slowIDCT + 2025-09-25 27c7bbc51c image/jpeg: prepare for new FDCT/IDCT implementations + 2025-09-24 f15cd63ec4 cmd/compile: don't rely on loop info when there are irreducible loops + 2025-09-24 371c1d2fcb cmd/internal/obj/riscv: add support for vector unit-stride fault-only-first load instructions + 2025-09-23 411c250d64 runtime: add specialized malloc functions for sizes up to 512 bytes + 2025-09-23 d7a38adf4c runtime: eliminate global span queue [green tea] + 2025-09-23 7bc1935db5 cmd/compile/internal: support new(expr) + 2025-09-23 eb78f13c9f doc/go_spec.html: document new(expr) + 2025-09-23 74cc463f9e go/token: add TestRemovedFileFileReturnsNil test + 2025-09-23 902dc27ae9 go/token: clear cache after grabbing the mutex in RemoveFile + 2025-09-23 a13d085a5b cmd/cgo: don't hardcode section name in TestNumberOfExportedFunctions + 2025-09-23 61bf26a9ee cmd/link: fix Macho-O X86_64_RELOC_SUBTRACTOR in internal linking + 2025-09-23 4b787c8c2b reflect: remove stale comment in unpackEface + 2025-09-23 3df27cd21a cmd/compile: fix typo in comment + 2025-09-23 684e8d3363 reflect: allocate memory in TypeAssert[I] only when the assertion succeeds + 2025-09-23 a5866ebe40 cmd/compile: prevent shapifying of pointer shape type + 2025-09-23 a27261c42f go/types,types2: allow new(expr) + 2025-09-23 e93f439ac4 runtime/cgo: retry when CreateThread fails with ERROR_ACCESS_DENIED + 2025-09-23 69e74b0aac runtime: deduplicate pMask resize code + 2025-09-23 fde10c4ce7 runtime: split gcMarkWorkAvailable into two separate conditions + 2025-09-23 5d040df092 runtime: use scan kernels in scanSpan [green tea] + 2025-09-23 7e0251bf58 runtime: don't report non-blocked goroutines as "(durable)" in stacks + 2025-09-23 22ac328856 cmd/link: make -w behavior consistent on Windows Change-Id: Id76b5a30a3b6f6669437f97e3320c9bca65a1e96
2025-09-25runtime: acquire/release C TSAN lock when calling cgo symbolizer/tracebackerMichael Pratt
When calling into C via cmd/cgo, the generated code calls _cgo_tsan_acquire / _cgo_tsan_release around the C call to report a dummy lock to the C/C++ TSAN runtime. This is necessary because the C/C++ TSAN runtime does not understand synchronization within Go and would otherwise report false positive race reports. See the comment in cmd/cgo/out.go for more details. Various C functions in runtime/cgo also contain manual calls to _cgo_tsan_acquire/release where necessary to suppress race reports. However, the cgo symbolizer and cgo traceback functions called from callCgoSymbolizer and cgoContextPCs, respectively, do not have any instrumentation [1]. They call directly into user C functions with no TSAN instrumentation. This means they have an opportunity to report false race conditions. The most direct way is via their argument. Both are passed a pointer to a struct stored on the Go stack, and both write to fields of the struct. If two calls are passed the same pointer from different threads, the C TSAN runtime will think this is a race. This is simple to achieve for the cgo symbolizer function, which the new regression test does. callCgoSymbolizer is called on the standard goroutine stack, so the argument is a pointer into the goroutine stack. If the goroutine moves Ms between two calls, it will look like a race. On the other hand, cgoContextPCs is called on the system stack. Each M has a unique system stack, so for it to pass the same argument pointer on different threads would require the first M to exit, free its stack, and the same region of address space to be used as the stack for a new M. Theoretically possible, but quite unlikely. Both of these are addressed by providing a C wrapper in runtime/cgo that calls _cgo_tsan_acquire/_cgo_tsan_release around calls to the symbolizer and traceback functions. There is a lot of room for future cleanup here. Most runtime/cgo functions have manual instrumentation in their C implementation. That could be removed in favor of instrumentation in the runtime. We could even theoretically remove the instrumentation from cmd/cgo and move it to cgocall. None of these are necessary, but may make things more consistent and easier to follow. [1] Note that the cgo traceback function called from the signal handler via x_cgo_callers _does_ have manual instrumentation. Fixes #73949. Cq-Include-Trybots: luci.golang.try:gotip-freebsd-amd64,gotip-linux-amd64-longtest,gotip-windows-amd64-longtest Change-Id: I6a6a636c9daa38f7fd00694af76b75cb93ba1886 Reviewed-on: https://go-review.googlesource.com/c/go/+/677955 Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-23runtime: add specialized malloc functions for sizes up to 512 bytesMichael Matloob
This CL adds a generator function in runtime/_mkmalloc to generate specialized mallocgc functions for sizes up throuht 512 bytes. (That's the limit where it's possible to end up in the no header case when there are scan bits, and where the benefits of the specialized functions significantly diminish according to microbenchmarks). If the specializedmalloc GOEXPERIMENT is turned on, mallocgc will call one of these functions in the no header case. malloc_generated.go is the generated file containing the specialized malloc functions. malloc_stubs.go contains the templates that will be stamped to create the specialized malloc functions. malloc_tables_generated contains the tables that mallocgc will use to select the specialized function to call. I've had to update the two stdlib_test.go files to account for the new submodule mkmalloc is in. mprof_test accounts for the changes in the stacks since different functions can be called in some cases. I still need to investigate heapsampling.go. Change-Id: Ia0f68dccdf1c6a200554ae88657cf4d686ace819 Reviewed-on: https://go-review.googlesource.com/c/go/+/665835 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-23runtime: eliminate global span queue [green tea]Michael Anthony Knyszek
This change removes the locked global span queue and replaces the fixed-size local span queue with a variable-sized local span queue. The variable-sized local span queue grows as needed to accomodate local work. With no global span queue either, GC workers balance work amongst themselves by stealing from each other. The new variable-sized local span queues are inspired by the P-local deque underlying sync.Pool. Unlike the sync.Pool deque, however, both the owning P and stealing Ps take spans from the tail, making this incarnation a strict queue, not a deque. This is intentional, since we want a queue-like order to encourage objects to accumulate on each span. These variable-sized local span queues are crucial to mark termination, just like the global span queue was. To avoid hitting the ragged barrier too often, we must check whether any Ps have any spans on their variable-sized local span queues. We maintain a per-P atomic bitmask (another pMask) that contains this state. We can also use this to speed up stealing by skipping Ps that don't have any local spans. The variable-sized local span queues are slower than the old fixed-size local span queues because of the additional indirection, so this change adds a non-atomic local fixed-size queue. This risks getting work stuck on it, so, similarly to how workbufs work, each worker will occasionally dump some spans onto its local variable-sized queue. This scales much more nicely than dumping to a global queue, but is still visible to all other Ps. For #73581. Change-Id: I814f54d9c3cc7fa7896167746e9823f50943ac22 Reviewed-on: https://go-review.googlesource.com/c/go/+/700496 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-23runtime/cgo: retry when CreateThread fails with ERROR_ACCESS_DENIEDqmuntal
_cgo_beginthread used to retry _beginthread only when it failed with EACCESS, but CL 651995 switched to CreateThread and incorrectly mapped EACCESS to ERROR_NOT_ENOUGH_MEMORY. The correct mapping is ERROR_ACCESS_DENIED. Fixes #72814 Fixes #75381 Change-Id: I8ba060114aae4e8249576f11a21eff613caa8001 Reviewed-on: https://go-review.googlesource.com/c/go/+/706075 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-09-23runtime: deduplicate pMask resize codeMichael Anthony Knyszek
Change-Id: I04a9a69904710a488c685cb9eee9c3313ed8e97b Reviewed-on: https://go-review.googlesource.com/c/go/+/701896 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-23runtime: split gcMarkWorkAvailable into two separate conditionsMichael Anthony Knyszek
Right now, gcMarkWorkAvailable is used in two scenarios. The first is critical: we use it to determine whether we're approaching mark termination, and it's crucial to reaching a fixed point across the ragged barrier in gcMarkDone. The second is a heuristic: should we spin up another GC worker? This change splits gcMarkWorkAvailable into these two separate conditions. This change also deduplicates the logic for updating work.nwait into more abstract helpers "gcBeginWork" and "gcEndWork." This change is solely refactoring, and should be a no-op. There are only two functional changes: - work.nwait is incremented after setting pp.gcMarkWorkerMode in the background worker code. I don't believe this change is observable except if the code fails to update work.nwait (either it results in a non-sensical number, or the stack is corrupted) in which case the goroutine may not be labeled as a mark worker in the resulting stack trace (it should be obvious from the stack frames though). - endCheckmarks also checks work.nwait == work.nproc, which should be fine since we never mutate work.nwait on that path. That extra check should be a no-op. Splitting these two use-cases for gcMarkWorkAvailable is conceptually helpful, and the checks may also diverge from Green Tea once we get rid of the global span queue. Change-Id: I0bec244a14ee82919c4deb7c1575589c0dca1089 Reviewed-on: https://go-review.googlesource.com/c/go/+/701176 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-23runtime: use scan kernels in scanSpan [green tea]Michael Anthony Knyszek
This is an extra 15-20% faster over the current sparse span scanning when AVX512+GFNI is available and there's sufficient density. For #73581. Change-Id: I9688e09885dd76c5ccab7c492c85a7e14e18ee04 Reviewed-on: https://go-review.googlesource.com/c/go/+/665495 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-09-23runtime: don't report non-blocked goroutines as "(durable)" in stacksDamien Neil
Only append the " (durable)" suffix to a goroutine's status when the goroutine is waiting. Avoids reporting a goroutine as "runnable (durable)". Change-Id: Id679692345afab6e63362ca3eeff16808367e50f Reviewed-on: https://go-review.googlesource.com/c/go/+/705995 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-09-23[dev.simd] cmd/compile: remove stores to unread parametersCherry Mui
Currently, we remove stores to local variables that are not read. We don't do that for arguments. But arguments and locals are essentially the same. Arguments are passed by value, and are not expected to be read in the caller's frame. So we can remove the writes to them as well. One exception is the cgo_unsafe_arg directive, which makes all the arguments effectively address-taken. cgo_unsafe_arg implies ABI0, so we just skip ABI0 functions' arguments. Change-Id: I8999fc50da6a87f22c1ec23e9a0c15483b6f7df8 Reviewed-on: https://go-review.googlesource.com/c/go/+/705815 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-09-23[dev.simd] all: merge master (9b2d39b) into dev.simdCherry Mui
Conflicts: - src/internal/buildcfg/exp.go Merge List: + 2025-09-22 9b2d39b75b cmd/compile/internal/ssa: match style and formatting + 2025-09-22 e23edf5e55 runtime: don't re-read metrics before check in TestReadMetricsSched + 2025-09-22 177cd8d763 log/slog: use a pooled json encoder + 2025-09-22 2353c15785 cmd/cgo/internal/test: skip TestMultipleAssign when using UCRT on Windows + 2025-09-22 32dfd69282 cmd/dist: disable FIPS 140-3 mode when testing maphash with purego + 2025-09-19 7f6ff5ec3e cmd/compile: fix doc word + 2025-09-19 9693b94be0 runtime: include stderr when objdump fails + 2025-09-19 8616981ce6 log/slog: optimize slog Level.String() to avoid fmt.Sprintf + 2025-09-19 b8af744360 testing: fix example for unexported identifier + 2025-09-19 51dc5bfe6c Revert "cmd/go: disable cgo by default if CC unset and DefaultCC doesn't exist" + 2025-09-19 ee7bf06cb3 time: improve ParseDuration performance for invalid input + 2025-09-19 f9e61a9a32 cmd/compile: duplicate nil check to two branches of write barrier + 2025-09-18 3cf1aaf8b9 runtime: use futexes with 64-bit time on Linux + 2025-09-18 0ab038af62 cmd/compile/internal/abi: use clear built-in + 2025-09-18 00bf24fdca bytes: use clear in test + 2025-09-18 f9701d21d2 crypto: use clear built-in + 2025-09-18 a58afe44fa net: fix testHookCanceledDial race + 2025-09-18 3203a5da29 net/http: avoid connCount underflow race + 2025-09-18 8ca209ec39 context: don't return a non-nil from Err before Done is closed + 2025-09-18 3032894e04 runtime: make explicit nil check in heapSetTypeSmallHeader + 2025-09-17 ef05b66d61 cmd/internal/obj/riscv: add support for Zicond instructions + 2025-09-17 78ef487a6f cmd/compile: fix the issue of shift amount exceeding the valid range + 2025-09-17 77aac7bb75 runtime: don't enable heap randomization if MSAN or ASAN is enabled + 2025-09-17 465b85eb76 runtime: fix CheckScavengedBitsCleared with randomized heap base + 2025-09-17 909704b85e encoding/json/v2: fix typo in comment + 2025-09-17 3db5979e8c testing: use reflect.TypeAssert and reflect.TypeFor + 2025-09-17 6a8dbbecbf path/filepath: fix EvalSymlinks to return ENOTDIR on plan9 + 2025-09-17 bffe7ad9f1 go/parser: Add TestBothLineAndLeadComment + 2025-09-17 02a888e820 go/ast: document that (*ast.File).Comments is sorted by position + 2025-09-16 594deca981 cmd/link: simplify PE relocations mapping + 2025-09-16 9df1a289ac go/parser: simplify expectSemi + 2025-09-16 72ba117bda internal/buildcfg: enable randomizedHeapBase64 by default + 2025-09-16 796ea3bc2e os/user: align test file name and build tags + 2025-09-16 a69395eab2 runtime/_mkmalloc: add a copy of cloneNode + 2025-09-16 cbdad4fc3c cmd/go: check pattern for utf8 validity before call regexp.MustCompile + 2025-09-16 c2d85eb999 cmd/go: disable cgo by default if CC unset and DefaultCC doesn't exist + 2025-09-16 ac82fe68aa bytes,strings: remove reference to non-existent SplitFunc + 2025-09-16 0b26678db2 cmd/compile: fix mips zerorange implementation + 2025-09-16 e2cfc1eb3a cmd/internal/obj/riscv: improve handling of float point moves + 2025-09-16 281c632e6e crypto/x509/internal/macos: standardize package name + 2025-09-16 61dc7fe30d iter: document that calling yield after terminated range loop causes runtime panic Change-Id: Ic06019efc855913632003f41eb10c746b3410b0a
2025-09-22runtime: don't re-read metrics before check in TestReadMetricsSchedMichael Anthony Knyszek
The two remaining popular flakes in TestReadMetricsSched are with waiting and not-in-go goroutines. I believe the reason for both of these is pollution due to other goroutines in the test binary, and we can be a little bit more robust to them. In particular, both of these tests spin until there's a particular condition met in the metrics. Then they both immediately re-read the metrics. The metrics being checked are not guaranteed to stay that way in the re-read. For example, for the waiting case, it's possible for >1000 to be waiting, but then some leftover goroutines from a previous test wake up off of some condition, causing the number to dip again on the re-read. This is supported by the fact that in some of these failures, the test takes very little time to execute (the condition that there are at least 1000 waiting goroutines is almost immediately satisfied) but it still fails (the re-read causes us to notice that there are <1000 waiting goroutines). This change makes the test more robust by not performing this re-read. This means more possible false negatives, but the error cases we're looking for (bad metrics) should still show up with some reasonable probability when something *is* truly wrong. For #75049. Change-Id: Idc3a8030bed8da51f24322efe15f3ff13da05623 Reviewed-on: https://go-review.googlesource.com/c/go/+/705875 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-19runtime: include stderr when objdump failsMichael Pratt
If objdump panics, we want the panic included in the test log. Change-Id: I6a6a636c13c5ba08acaa1c6c8714541a8e91542b Reviewed-on: https://go-review.googlesource.com/c/go/+/704338 Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-18runtime: use futexes with 64-bit time on LinuxDaniel Maslowski
Linux introduced new syscalls to fix the year 2038 issue. To still be able to use the old ones, the Kconfig option COMPAT_32BIT_TIME would be necessary. Use the new syscall with 64-bit values for futex by default. Define _ENOSYS for detecting if it's not available. Add a fallback to use the older syscall in case the new one is not available, since Go runs on Linux from 2.6.32 on, per https://go.dev/wiki/MinimumRequirements. Updates #75133 Change-Id: I65daff0a3d06b55440ff05d8f5a9aa1c07eb201d GitHub-Last-Rev: 96dd1bd84bd12d898e971157fc83da562cc4f6b4 GitHub-Pull-Request: golang/go#75306 Reviewed-on: https://go-review.googlesource.com/c/go/+/701615 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-18runtime: make explicit nil check in heapSetTypeSmallHeaderMichael Pratt
This is another case very similar to CL 684015 and #74375. In spans with type headers, mallocgc always writes to the page before returning the allocated memory. This initial write is done by runtime.heapSetTypeSmallHeader. Prior to the write, the compiler inserts a nil check, implemented as a dummy instruction reading from memory. On a freshly mapped page, this read triggers a page fault, mapping the zero page read-only. Immediately afterwards, the write triggers another page fault, copying to a writeable page and performing a TLB flush. This problem is exacerbated as the process scales up. At GOMAXPROCS=6, the tile38 sweet benchmark spends around 0.1% of cycles directly handling these page faults. On the same machine at GOMAXPROCS=192, it spends about 2.7% of cycles directly handling these page faults. Replacing the read with an explicit nil check reduces the direct cost of these page faults down to around 0.1% at GOMAXPROCS=192. There are additional positive side-effects due to reduced contention, so the overall time spent in page faults drops from around 12.8% to 6.8%. Most of the remaining time in page faults is spent on automatic NUMA page migration (completely unrelated to this issue). Impact on the tile38 benchmark results: │ baseline │ cl704755 │ │ sec/op │ sec/op vs base │ Tile38QueryLoad-192 1.638m ± 3% 1.494m ± 5% -8.79% (p=0.002 n=6) │ baseline │ cl704755 │ │ average-RSS-bytes │ average-RSS-bytes vs base │ Tile38QueryLoad-192 5.384Gi ± 3% 5.399Gi ± 3% ~ (p=0.818 n=6) │ baseline │ cl704755 │ │ peak-RSS-bytes │ peak-RSS-bytes vs base │ Tile38QueryLoad-192 5.818Gi ± 1% 5.864Gi ± 2% ~ (p=0.394 n=6) │ baseline │ cl704755 │ │ peak-VM-bytes │ peak-VM-bytes vs base │ Tile38QueryLoad-192 7.121Gi ± 1% 7.180Gi ± 2% ~ (p=0.818 n=6) │ baseline │ cl704755 │ │ p50-latency-sec │ p50-latency-sec vs base │ Tile38QueryLoad-192 343.2µ ± 1% 313.2µ ± 3% -8.73% (p=0.002 n=6) │ baseline │ cl704755 │ │ p90-latency-sec │ p90-latency-sec vs base │ Tile38QueryLoad-192 1.662m ± 2% 1.603m ± 5% ~ (p=0.093 n=6) │ baseline │ cl704755 │ │ p99-latency-sec │ p99-latency-sec vs base │ Tile38QueryLoad-192 41.56m ± 8% 35.26m ± 18% -15.17% (p=0.026 n=6) │ baseline │ cl704755 │ │ ops/s │ ops/s vs base │ Tile38QueryLoad-192 87.89k ± 3% 96.36k ± 4% +9.64% (p=0.002 n=6) Updates #74375. Change-Id: I6a6a636c1a16261b6d5076f2e1b08524a6544d33 Reviewed-on: https://go-review.googlesource.com/c/go/+/704755 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2025-09-17runtime: don't enable heap randomization if MSAN or ASAN is enabledRoland Shoemaker
MSAN and ASAN do confusing things to the memory layout, which are likely to conflict with heap base randomization, so if they are enabled, ignore randomizedHeapBase64. We already didn't turn it on when TSAN was enabled. Change-Id: I41e59dfc33d8bb059c208a9595442571fb31eea3 Reviewed-on: https://go-review.googlesource.com/c/go/+/704856 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Roland Shoemaker <roland@golang.org>
2025-09-17runtime: fix CheckScavengedBitsCleared with randomized heap baseRoland Shoemaker
We cannot easily determine the base address of the arena we added the random padding pages to, which can cause confusing TestScavengedBitsCleared failures when the arena we padded does not have the lowest address of all of the arenas. Instead of attempting to determine the correct arena to ignore when checking the scav and alloc bits, switch to just tolerating _one_ arena having mismatches, which is expected when randomizedHeapBase64 is enabled. Any other number of arenas having mismatches is likely a real error. Fixes #75502 Change-Id: Iacc445b2905824f9f71970c7abd33f187793cf39 Reviewed-on: https://go-review.googlesource.com/c/go/+/704855 Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Roland Shoemaker <roland@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-16runtime/_mkmalloc: add a copy of cloneNodeMichael Matloob
cloneNode is defined in golang.org/x/tools/internal/astutil. Make a copy of it so we can easily clone AST nodes. Change-Id: I6a6a6964132e663e64faa00fa6037cf6e8d4cbc6 Reviewed-on: https://go-review.googlesource.com/c/go/+/703396 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
2025-09-16[dev.simd] all: merge master (ca0e035) into dev.simdCherry Mui
Conflicts: - src/internal/goexperiment/flags.go Merge List: + 2025-09-15 ca0e03560d cmd/link: remove support for windows/arm relocations + 2025-09-15 17a0fabc43 cmd/link: remove support for darwin/386 relocations + 2025-09-15 eb7c67fdc9 cmd/internal/obj/loong64: use the MOVVP instruction to optimize prologue + 2025-09-15 6b8d507508 cmd/internal/obj/riscv: implement vector segment load/store instructions + 2025-09-15 7ddbf4d820 cmd/asm: add double precision comparision testcases for riscv64 + 2025-09-15 c39abe0658 runtime: fix TestSehUnwind + 2025-09-15 e3ed0fbe6a all: replace strings.Split with strings.SplitSeq + 2025-09-15 10bfddc91d all: remove redundant words in comment + 2025-09-15 2469e92d8c cmd/compile: combine doubling with shift on riscv64 + 2025-09-15 aa83aee7de net/http: clarify panic conditions in Handle, HandleFunc, AddInsecureBypassPattern + 2025-09-15 b9e2977f1d crypto/internal/cryptotest: use linux-amd64_avx512 builder for SHA-NI + 2025-09-15 8105d0ccc2 cmd/go,crypto/internal/fips140: prevent using FIPS 140-3 mode with purego tag + 2025-09-15 7f70ca8726 crypto/internal/cryptotest: add MustSupportFIPS140 + 2025-09-15 9e71d8a9f7 cmd/internal/testdir: re-enable default all codegen flag on linux-amd64 + 2025-09-15 004858ccdd all: replace os.Getenv("GO_BUILDER_NAME") with testenv.Builder in tests + 2025-09-15 dbde15800c cmd: vendor x/tools@9fccddc + 2025-09-15 8ace10dad2 os: add (*Process).WithHandle + 2025-09-15 3573227fe3 os: add and use errProcessReleased + 2025-09-15 68c6a73380 internal/syscall/unix: add KernelVersionGE + 2025-09-15 e603e9834e cmd/link: support race mode with MSVC clang + 2025-09-15 e5ee1f2600 test/codegen: check zerobase for newobject on 0-sized types + 2025-09-15 77b93d41d5 net/http: add comments for transport gzip reader + 2025-09-15 30d510ca2d cmd/compile,cmd/gofmt: use reflect.TypeFor + 2025-09-15 8320fe8f0e runtime: deduplicate syscall assembly for darwin + 2025-09-14 080882a928 net: use context.AfterFunc in connect + 2025-09-12 ac803b5949 cmd/go/internal/work: copy vet tool's stdout to our stdout + 2025-09-12 889e71c2ac runtime: move Windows types and consts to internal/runtime/syscall/windows + 2025-09-12 cc8a6780ac vendor: update x/tools to 3adf0e9, and other repos + 2025-09-12 911455fe18 cmd/link: don't count tbss section in TestFlagD + 2025-09-12 f1fd13016a cmd/compile: optimize abi.Type.GCData loads + 2025-09-12 dc960d0bfe cmd/compile, reflect: further allow inlining of TypeFor + 2025-09-12 7acb0d0446 runtime: fix syscall9 on darwin/arm64 + 2025-09-12 60c1ee9183 internal/goexperiment: add a sizespecializedmalloc goexperiment setting + 2025-09-12 c70713da82 cmd/link: support MSVC clang + 2025-09-12 9271bbbb80 internal/testenv: update Builder docs with LUCI builder names + 2025-09-12 a4e25c3d65 net,internal/poll: skip TestAllocs when race is enabled on Windows + 2025-09-12 dd8276657f cmd/asm, cmd/internal/obj: add riscv64 generic CSR ops + 2025-09-11 f37d75472d runtime: move mksizeclasses.go to runtime/_mkmalloc + 2025-09-11 73676e3223 cmd/go: run cgo and cgo compiles in their own actions + 2025-09-11 0e1b98993e testing: exit B.Loop early upon saturation + 2025-09-11 84e9ab3984 cmd/go/internal/work: remove deps[1]="fmt" vet hack Change-Id: I1424228bcd9291c9ff29f6ae843d5b90652f237e
2025-09-15runtime: fix TestSehUnwindqmuntal
The various TestSehUnwind tests recently started to fail due an unrelated refactor (in CL 698098) that made the stack frames to not match the expected pattern. This CL updates the tests to be more robust to such changes. Fixes #75467 Change-Id: I7950332bb6ca54e4bf693d13e2490b3d9d901dde Reviewed-on: https://go-review.googlesource.com/c/go/+/703779 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-09-15internal/syscall/unix: add KernelVersionGEKir Kolyshkin
There are a few places in the code which checks that the running kernel is greater than or equal to x.y. The check takes a few lines and the checking code is somewhat distracting. Let's abstract this check into a simple function, KernelVersionGE, and convert the users accordingly. Add a test case (I'm not sure it has much value, can be dropped). Change-Id: I8ec91dcc7452363361f95e46794701c0ae57d956 Reviewed-on: https://go-review.googlesource.com/c/go/+/700796 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com>
2025-09-15runtime: deduplicate syscall assembly for darwinqmuntal
The darwin port provides different syscall functions that only differ on how they handle the errors, and they are all written in assembly. This duplication can be removed by factoring out the error handling logic to arch-agnostic Go code and leaving the assembly functions with the only reponsibility of making the syscall and mapping parameters between ABIs. Updates #51087 Cq-Include-Trybots: luci.golang.try:gotip-darwin-arm64-longtest,gotip-darwin-amd64-longtest Change-Id: I9524377f3ef9c9a638412c7e87c8f46a33ee3453 Reviewed-on: https://go-review.googlesource.com/c/go/+/699135 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-12runtime: move Windows types and consts to internal/runtime/syscall/windowsqmuntal
This CL doesn't change any behavior, it just moves code around to reduce the size of the runtime package and remove some duplicated symbols. Updates #51087. Cq-Include-Trybots: luci.golang.try:gotip-windows-arm64 Change-Id: I3d3e5f214f045c24fb5d4050d56e7b0822a6e4b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/698098 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-09-12runtime: fix syscall9 on darwin/arm64qmuntal
The aarch64 ABI says that only the first 8 arguments should be passed as registers, subsequent arguments should be put on the stack. Syscall9 is not putting the 9th argument on the stack, and it should. The standard library hasn't hit this issue because it uses Syscall9 for functions that only require 7 or 8 parameters. Change-Id: I1fafca5b16f977ea856e3f08b4ff3d0a2a7a4dfe Reviewed-on: https://go-review.googlesource.com/c/go/+/702297 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-11runtime: move mksizeclasses.go to runtime/_mkmallocmatloob
This will allow us to share code with the specialized malloc code generator. Change-Id: I6a6a696450a5039a957811fb06228122d494ddce Reviewed-on: https://go-review.googlesource.com/c/go/+/700495 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
2025-09-11[dev.simd] all: merge master (cf5e993) into dev.simdCherry Mui
Merge List: + 2025-09-11 cf5e993177 cmd/link: allow one to specify the data section in the internal linker + 2025-09-11 cdb3d467fa encoding/gob: make use of reflect.TypeAssert + 2025-09-11 fef360964c archive/tar: fix typo in benchmark name + 2025-09-11 7d562b8460 syscall: actually remove unreachable code + 2025-09-11 c349582344 crypto/rsa: don't test CL 687836 against v1.0.0 FIPS 140-3 module + 2025-09-11 253dd08f5d debug/macho: filter non-external symbols when reading imported symbols without LC_DYSYMTAB + 2025-09-10 2009e6c596 internal/runtime/maps: remove redundant package docs + 2025-09-10 de5d7eccb9 runtime/internal/maps: only conditionally clear groups when sparse + 2025-09-10 8098b99547 internal/runtime/maps: speed up Clear + 2025-09-10 fe5420b054 cmd: delete some more windows/arm remnants + 2025-09-10 fad1dc608d runtime: don't artificially limit TestReadMetricsSched + 2025-09-10 b1f3e38e41 cmd/compile: when CSEing two values, prefer the statement marked one + 2025-09-10 00824f5ff5 types2: better documentation for resolve() + 2025-09-10 5cf8ca42e3 internal/trace/raw: use strings.Cut instead of strings.SplitN 2 + 2025-09-10 80a2aae922 Revert "cmd/compile: improve stp merging for non-sequent cases" + 2025-09-10 f327a05419 go/token, syscall: annotate if blocks that defeat vet's unreachable pass + 2025-09-10 9650c97d0f syscall: remove unreachable code + 2025-09-10 f1c4b860d4 Revert "crypto/internal/fips140: update frozen module version to "v1.0.0"" + 2025-09-10 30686c4cc8 encoding/json/v2: document context annotation with SemanticError + 2025-09-09 c5737dc21b runtime: when using cgo on 386, call C sigaction function + 2025-09-09 b9a4a09b0f runtime: remove duff support for riscv64 + 2025-09-09 4dac9e093f cmd/compile: use generated loops instead of DUFFCOPY on riscv64 + 2025-09-09 879ff736d3 cmd/compile: use generated loops instead of DUFFZERO on riscv64 + 2025-09-09 77643dc63f cmd/compile: simplify zerorange on riscv64 + 2025-09-09 e6605a1bcc encoding/json: use reflect.TypeAssert + 2025-09-09 4c20f7f15a cmd/cgo: run gcc to get errors and debug info in parallel + 2025-09-09 5dcedd6550 runtime: lock mheap_.speciallock when allocating synctest specials + 2025-09-09 d3be949ada runtime: don't negate eventfd errno + 2025-09-09 836fa74518 syscall: optimise cgo clearenv + 2025-09-09 ce39174482 crypto/rsa: check PrivateKey.D for consistency with Dp and Dq + 2025-09-09 5d9d0513dc crypto/rsa: check for post-Precompute changes in Validate + 2025-09-09 968a5107a9 crypto/internal/fips140: update frozen module version to "v1.0.0" + 2025-09-09 645ee44492 crypto/ecdsa: deprecate direct use of big.Int fields in keys + 2025-09-09 a67977da5e cmd/compile/internal/inline: ignore superfluous slicing + 2025-09-09 a5fa5ea51c cmd/compile/internal/ssa: expand runtime.memequal for length {3,5,6,7} + 2025-09-09 4c63d798cb cmd/compile: improve stp merging for non-sequent cases + 2025-09-09 bdd51e7855 cmd/compile: use constant zero register instead of specialized zero instructions on mips64x + 2025-09-09 10ac80de77 cmd/compile: introduce CCMP generation + 2025-09-09 3b3b16957c Revert "cmd/go: use os.Rename to move files on Windows" + 2025-09-09 e3223518b8 cmd/go: split generating cover files into its own action + 2025-09-09 af03343f93 cmd/compile: fix bounds check report + 2025-09-08 6447ff409a cmd/compile: fold constant in ADDshift op on loong64 + 2025-09-08 5b218461f9 cmd/compile: optimize loads from abi.Type.{Size_,PtrBytes,Kind_} + 2025-09-08 b915e14490 cmd/compile: consolidate logic for rewriting fixed loads + 2025-09-08 06e791c0cd cmd/compile: simplify zerorange on mips + 2025-09-08 cf42b785b7 cmd/cgo: run recordTypes for each of the debugs at the end of Translate + 2025-09-08 5e6296f3f8 archive/tar: optimize nanosecond parsing in parsePAXTime + 2025-09-08 ea00650784 debug/pe: permit symbols with no name + 2025-09-08 4cc7cc74c3 crypto: update Hash comments to point to crypto/sha3 + 2025-09-08 ff45d5d53c encoding/json/internal/jsonflags: fix comment with wrong field name + 2025-09-06 861c90c907 net/http: pool transport gzip readers + 2025-09-06 57769b5532 os: reject OpenDir of a non-directory file in Plan 9 + 2025-09-06 a6144613d3 crypto/tls: use context.AfterFunc in handshakeContext + 2025-09-05 e8126bce9e runtime/cgo: save and restore R31 for crosscall1 on loong64 + 2025-09-05 d767064170 cmd/compile: mark abi.PtrType.Elem sym as used + 2025-09-05 0b1eed09a3 vendor/golang.org/x/tools: update to a09a2fb + 2025-09-05 f5b20689e9 cmd/compile: optimize loads from readonly globals into constants on loong64 + 2025-09-05 3492e4262b cmd/compile: simplify specific addition operations using the ADDV16 instruction + 2025-09-05 459b85ccaa cmd/fix: remove all functionality except for buildtag + 2025-09-05 87e72769fa runtime: simplify openbsd check in usesLibcall and mStackIsSystemAllocated + 2025-09-05 bb48272e24 cmd/compile: simplify zerorange on mips64 + 2025-09-05 d52a56cce1 cmd/link/internal/ld: unconditionally use posix_fallocate on FreeBSD + 2025-09-04 9d0829963c net/http: fix cookie value of "" being interpreted as empty string. + 2025-09-04 ddce0522be cmd/internal/obj/loong64: add ADDU16I.D instruction support + 2025-09-04 00b8474e47 cmd/trace: don't filter events for profile by whether they have stack + 2025-09-04 e36c5aead6 log/slog: add multiple handlers support for logger + 2025-09-04 150fae714e crypto/x509: don't force system roots load in SetFallbackRoots + 2025-09-04 4f7bbc62c7 runtime, cmd/compile, cmd/internal/obj: remove duff support for loong64 + 2025-09-04 b8cc907425 cmd/internal/obj/loong64: fix the usage of offset in the instructions [X]VLDREPL.{B/H/W/D} + 2025-09-04 8c27a80890 path{,/filepath}: speed up Match + 2025-09-04 b7c20413c5 runtime: remove obsolete osArchInit function + 2025-09-04 df29038486 cmd/compile/internal/ssa: load constant values from abi.PtrType.Elem + 2025-09-04 4373754bc9 cmd/compile: add store to load forwarding rules on riscv64 + 2025-09-03 80038586ed cmd/compile: export to DWARF types only referenced through interfaces + 2025-09-03 91e76a513b cmd/compile: use generated loops instead of DUFFCOPY on loong64 + 2025-09-03 c552ad913f cmd/compile: simplify memory load and store operations on loong64 + 2025-09-03 e8f9127d1f net/netip: export Prefix.Compare, fix ordering + 2025-09-03 731e546166 cmd/compile: simplify the support for 32bit high multiply on loong64 Change-Id: I2c124fb8071e2972d39804867cafb6806e601aba
2025-09-10runtime: don't artificially limit TestReadMetricsSchedqmuntal
TestReadMetricsSched/running can take some time to enter in steady state on busy systems. We currently only allow 1 second for that, we should let it run unlimitedly until success or the test time's out. Fixes #75049 Change-Id: I452059e1837caf12a2d2d9cae1f70a0ef2d4f518 Reviewed-on: https://go-review.googlesource.com/c/go/+/702295 Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-09-09runtime: when using cgo on 386, call C sigaction functionIan Lance Taylor
On 386 the C sigaction function assumes that the caller does not set the SA_RESTORER flag. It does not copy the C sa_restorer field to the kernel sa_restorer field. The effect is that the kernel sees the SA_RESTORER flag but a NULL sa_restorer field, and the program crashes when returning from a signal handler. On the other hand, the C sigaction function will return the SA_RESTORER flag and the sa_restorer field stored in the kernel. This means that if the Go runtime installs a signal handler, with SA_RESTORER as is required when calling the kernel, and the Go program calls C code that calls the C sigaction function to query the current signal handler, that C code will get a result that it can't pass back to sigaction. This CL fixes the problem by using the C sigaction function for 386 programs that use cgo. This reuses the functionality used on amd64 and other GOARCHs to support the race detector. See #75253, or runtime/testdata/testprogcgo/eintr.go, for sample code that used to fail on 386. No new test case is required, we just remove the skip we used to have for eintr.go. Fixes #75253 Change-Id: I803059b1fb9e09e9fbb43f68eccb6a59a92c2991 Reviewed-on: https://go-review.googlesource.com/c/go/+/701375 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-09-09runtime: remove duff support for riscv64Meng Zhuo
Change-Id: I987d9f49fbd2650eef4224f72271bf752c54d39c Reviewed-on: https://go-review.googlesource.com/c/go/+/700538 Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
2025-09-09runtime: lock mheap_.speciallock when allocating synctest specialsDamien Neil
Avoid racing use of mheap_.specialBubbleAlloc. Fixes #75134 Change-Id: I0c9140c18d2bca1e1c3387cd81230f0e8c9ac23e Reviewed-on: https://go-review.googlesource.com/c/go/+/699255 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-09runtime: don't negate eventfd errnoMichael Pratt
The Linux syscall package does this for us. Fixes #75337. Change-Id: I6a6a636c9bb5fe25fdc6f80dc8b538ebed60d00b Reviewed-on: https://go-review.googlesource.com/c/go/+/701796 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2025-09-09syscall: optimise cgo clearenvAleksa Sarai
For programs with very large environments, calling unsetenv(3) for each environment variable can be very expensive because of CGo overhead, but clearenv(3) is much faster. The only thing we have to track is whether GODEBUG is being unset by the operation, which can be done very quickly without resorting to doing unsetenv(3) for every variable. This change makes syscall.Clearenv() >98% faster when run in an environment with as little as 100 environment variables. (Note that due to golang/go#27217, it is necessary to modify BenchmarkClearenv to use t.StopTimer() and -benchtime=100x in order to get these benchmark times -- otherwise syscall.Setenv() time is included and the benchmarks give a more pessimistic 50% performance improvement.) goos: linux goarch: amd64 pkg: syscall cpu: AMD Ryzen 7 7840U w/ Radeon 780M Graphics │ before │ after │ │ sec/op │ sec/op vs base │ Clearenv/100-16 22276.5n ± 5% 285.8n ± 3% -98.72% (p=0.000 n=10) Clearenv/1000-16 1414104.0n ± 1% 783.1n ± 8% -99.94% (p=0.000 n=10) Clearenv/10000-16 143827.554µ ± 1% 7.591µ ± 5% -99.99% (p=0.000 n=10) geomean 1.655m 1.193µ -99.93% The above benchmarks are CGo builds, which require CGo overhead for every setenv(2). If you run the same benchmarks for a non-CGo package (i.e., outside of the "syscall" package), you get slightly more modest performance improvements: goos: linux goarch: amd64 pkg: clearenv_nocgo cpu: AMD Ryzen 7 7840U w/ Radeon 780M Graphics │ before │ after │ │ sec/op │ sec/op vs base │ Clearenv/100-16 1106.0n ± 3% 230.7n ± 8% -79.14% (p=0.000 n=10) Clearenv/1000-16 11222.0n ± 1% 305.4n ± 6% -97.28% (p=0.000 n=10) Clearenv/10000-16 195676.5n ± 6% 759.9n ± 10% -99.61% (p=0.000 n=10) geomean 13.44µ 376.9n -97.20% (As above, this requires modifying the benchmarks to use t.StopTimer() and -benchtime=100x.) Change-Id: I53b96a75f189e91affbde423c907888b7e0fafcd GitHub-Last-Rev: f8d7a8140d8490189d726eb380522dccacc5f176 GitHub-Pull-Request: golang/go#70672 Reviewed-on: https://go-review.googlesource.com/c/go/+/633515 Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com>
2025-09-05runtime/cgo: save and restore R31 for crosscall1 on loong64Guoqi Chen
According to the Loong64 procedure call standard [1], R31 is a static register and therefore needs to be saved and restored. Also, the R2 (thread pointer) register has been removed here, as it is not involved in allocation. [1]: https://github.com/loongson/la-abi-specs/blob/release/lapcs.adoc Change-Id: I02e5d4bedf131e491f1a262aa3cbc0896cbc9488 Reviewed-on: https://go-review.googlesource.com/c/go/+/700817 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn> Reviewed-by: Meidan Li <limeidan@loongson.cn> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-09-05runtime: simplify openbsd check in usesLibcall and mStackIsSystemAllocatedTobias Klauser
The openbsd/mips64 runtime code was removed in CL 649659. For #61546 Change-Id: I03f16c3396baddb0ee9aa751dd6f699a835e7586 Reviewed-on: https://go-review.googlesource.com/c/go/+/700976 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Joel Sing <joel@sing.id.au> 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>
2025-09-04runtime, cmd/compile, cmd/internal/obj: remove duff support for loong64limeidan
Change-Id: I44d6452933c8010f7dfbf821a32053f9d1cf151e Reviewed-on: https://go-review.googlesource.com/c/go/+/700096 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2025-09-04runtime: remove obsolete osArchInit functionaimuz
The osArchInit function was introduced as a workaround for a Linux kernel bug that corrupted vector registers on x86 CPUs during signal delivery. The bug was introduced in Linux 5.2 and fixed in 5.3.15, 5.4.2, and all 5.5 and later kernels. The fix was also back-ported by major distros. Change-Id: I59990a7df104843955301c5cb8a547614eba145b GitHub-Last-Rev: 8425af458bfaad0d64d21ff3f3e0049d186f44ed GitHub-Pull-Request: golang/go#75246 Reviewed-on: https://go-review.googlesource.com/c/go/+/700555 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2025-09-03[dev.simd] all: merge master (4c4cefc) into dev.simdCherry Mui
Merge List: + 2025-09-03 4c4cefc19a cmd/gofmt: simplify logic to process arguments + 2025-09-03 925a3cdcd1 unicode/utf8: make DecodeRune{,InString} inlineable + 2025-09-03 3e596d448f math: rename Modf parameter int to integer + 2025-09-02 2a7f1d47b0 runtime: use one more address bit for tagged pointers + 2025-09-02 b09068041a cmd/dist: run racebench tests only in longtest mode + 2025-09-02 355370ac52 runtime: add comment for concatstring2 + 2025-09-02 1eec830f54 go/doc: linkify interface methods + 2025-08-31 7bba745820 cmd/compile: use generated loops instead of DUFFZERO on loong64 + 2025-08-31 882335e2cb cmd/internal/obj/loong64: add LDPTR.{W/D} and STPTR.{W/D} instructions support + 2025-08-31 d4b17f5869 internal/runtime/atomic: reset wrong jump target in Cas{,64} on loong64 + 2025-08-31 6a08e80399 net/http: skip redirecting in ServeMux when URL path for CONNECT is empty + 2025-08-29 8bcda6c79d runtime/race: add race detector support for linux/riscv64 + 2025-08-29 8377adafc5 cmd/cgo: split loadDWARF into two parts + 2025-08-29 a7d9d5a80a cmd/cgo: move typedefs and typedefList out of Package + 2025-08-29 1d459c4357 all: delete more windows/arm remnants + 2025-08-29 27ce6e4e26 cmd/compile: remove sign extension before MULW on riscv64 + 2025-08-29 84b070bfb1 cmd/compile/internal/ssa: make oneBit function generic + 2025-08-29 fe42628dae internal/cpu: inline DebugOptions + 2025-08-29 94b7d519bd net: update document on limitation of iprawsock on Windows + 2025-08-29 ba9e1ddccf testing: allow specify temp dir by GOTMPDIR environment variable + 2025-08-29 9f6936b8da cmd/link: disallow linkname of runtime.addmoduledata + 2025-08-29 89d41d254a bytes, strings: speed up TrimSpace + 2025-08-29 38204e0872 testing/synctest: call out common issues with tests + 2025-08-29 252c901125 os,syscall: pass file flags to CreateFile on Windows + 2025-08-29 53515fb0a9 crypto/tls: use hash.Cloner + 2025-08-28 13bb48e6fb go/constant: fix complex != unknown comparison + 2025-08-28 ba1109feb5 net: remove redundant cgoLookupCNAME return parameter + 2025-08-28 f74ed44ed9 net/http/httputil: remove redundant pw.Close() call in DumpRequestOut + 2025-08-28 a9689d2e0b time: skip TestLongAdjustTimers in short mode on single CPU systems + 2025-08-28 ebc763f76d syscall: only get parent PID if SysProcAttr.Pdeathsig is set + 2025-08-28 7f1864b0a8 strings: remove redundant "runs" from string.Fields docstring + 2025-08-28 90c21fa5b6 net/textproto: eliminate some bounds checks + 2025-08-27 e47d88beae os: return nil slice when ReadDir is used with a file on file_windows + 2025-08-27 6b837a64db cmd/internal/obj/loong64: simplify buildop + 2025-08-27 765905e3bd debug/elf: don't panic if symtab too small + 2025-08-27 2ee4b31242 net/http: Ensure that CONNECT proxied requests respect MaxResponseHeaderBytes + 2025-08-27 b21867b1a2 net/http: require exact match for CrossSiteProtection bypass patterns + 2025-08-27 d19e377f6e cmd/cgo: make it safe to run gcc in parallel + 2025-08-27 49a2f3ed87 net: allow zero value destination address in WriteMsgUDPAddrPort + 2025-08-26 afc51ed007 internall/poll: remove bufs field from Windows' poll.operation + 2025-08-26 801b74eb95 internal/poll: remove rsa field from Windows' poll.operation + 2025-08-26 fa18c547cd syscall: sort Windows env block in StartProcess + 2025-08-26 bfd130db02 internal/poll: don't use stack-allocated WSAMsg parameters + 2025-08-26 dae9e456ae runtime: identify virtual memory layout for riscv64 + 2025-08-25 25c2d4109f math: use Trunc to implement Modf + 2025-08-25 4e05a070c4 math: implement IsInf using Abs + 2025-08-25 1eed4f32a0 math: optimize Signbit implementation slightly + 2025-08-25 bd71b94659 cmd/compile/internal: optimizing add+sll rule using ALSLV instruction on loong64 + 2025-08-25 ea55ca3600 runtime: skip doInit of plugins in runtime.main + 2025-08-25 9ae2f1fb57 internal/trace: skip async preempt off tests on low end systems + 2025-08-25 bbd5342a62 net: fix cgoResSearch + 2025-08-25 ed7f804775 os: set full name for Roots created with Root.OpenRoot + 2025-08-25 a21249436b internal/poll: use fdMutex to provide read/write locking on Windows + 2025-08-24 44c5956bf7 test/codegen: add Mul2 and DivPow2 test for loong64 + 2025-08-24 0aa8019e94 test/codegen: add Mul* test for loong64 + 2025-08-24 83420974b7 test/codegen: add sqrt* abs and copysign test for loong64 + 2025-08-23 f2db0dca0b net/http/httptest: redirect example.com requests to server + 2025-08-22 d86ec92499 internal/syscall/windows: increase internal Windows O_ flags values + 2025-08-22 9d3f7fda70 crypto/tls: fix quic comment typo + 2025-08-22 78a05c541f internal/poll: don't pass non-nil WSAMsg.Name with 0 namelen on windows + 2025-08-22 52c3f73fda runtime/metrics: improve doc + 2025-08-22 a076f49757 os: fix Root.MkdirAll to handle race of directory creation + 2025-08-22 98238fd495 all: delete remaining windows/arm code + 2025-08-21 1ad30844d9 cmd/asm: process forward jump to PCALIGN + 2025-08-21 13c082601d internal/poll: permit nil destination address in WriteMsg{Inet4,Inet6} + 2025-08-21 9b0a507735 runtime: remove remaining windows/arm files and comments + 2025-08-21 1843f1e9c0 cmd/compile: use zero register instead of specialized *zero instructions on loong64 + 2025-08-21 e0870a0a12 cmd/compile: simplify zerorange on loong64 + 2025-08-21 fb8bbe46d5 cmd/compile/internal/ssa: eliminate unnecessary extension operations + 2025-08-21 9632ba8160 cmd/compile: optimize some patterns into revb2h/revb4h instruction on loong64 + 2025-08-21 8dcab6f450 syscall: simplify execve handling on libc platforms + 2025-08-21 ba840c1bf9 cmd/compile: deduplication in the source code generated by mknode + 2025-08-21 fa706ea50f cmd/compile: optimize rule (x + x) << c to x << c+1 on loong64 + 2025-08-21 ffc85ee1f1 cmd/internal/objabi,cmd/link: add support for additional riscv64 relocations Change-Id: I3896f74b1a3cc0a52b29ca48767bb0ba84620f71
2025-09-02runtime: use one more address bit for tagged pointersKeith Randall
We use one extra bit to placate systems which simulate amd64 binaries on an arm64 host. Allocated arm64 addresses could be as high as 1<<48-1, which would be invalid if we assumed 48-bit sign-extended addresses. (Note that this does not help the other way around, simluating arm64 on amd64, but we don't have that problem at the moment.) Fixes #69255 Change-Id: Iace17a5d41a65e34abf201d03d8b0ff6f7bf1150 Reviewed-on: https://go-review.googlesource.com/c/go/+/700515 Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-09-02[dev.simd] internal/cpu: report AVX1 and 2 as supported on macOS 15 Rosetta 2Cherry Mui
Apparently, on macOS 15 or newer, Rosetta 2 supports AVX1 and 2. However, neither CPUID nor the Apple-recommended sysctl says it has AVX. If AVX is used without checking the CPU feature, it may run fine without SIGILL, but the runtime doesn't know AVX is available therefore save and restore its states. This may lead to value corruption. Check if we are running under Rosetta 2 on macOS 15 or newer. If so, report AVX1 and 2 as supported. Change-Id: Ib981379405b1ae28faa378f051096827d760a4cc Reviewed-on: https://go-review.googlesource.com/c/go/+/700055 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-09-02runtime: add comment for concatstring2Youlin Feng
People always want to remove concatstring{2,3,4,5} for performance, but we keep them to make the binary smaller. So, add a comment to document why. Updates #65020 Change-Id: I819976b700d45ce4d0846bf4481b2654b85708da Reviewed-on: https://go-review.googlesource.com/c/go/+/700095 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2025-08-29runtime/race: add race detector support for linux/riscv64Joel Sing
This enables support for the race detector on linux/riscv64. Fixes #64345 Cq-Include-Trybots: luci.golang.try:gotip-linux-riscv64 Change-Id: I98962827e91455404858549b0f9691ee438f104b Reviewed-on: https://go-review.googlesource.com/c/go/+/690497 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Carlos Amedee <carlos@golang.org>