aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/race
AgeCommit message (Collapse)Author
2026-03-30runtime/race: allow TestOutput output in either orderMichael Pratt
We have only seen the wrappersym case reported in the opposite order in practice, but since these are intentionally racy, they could theoretically all occur in the opposite order. It would be nice to have a bit more structure to these tests so the test itself could easily flip the order. However, since they are just regular expressions, for now I've simply listed both orders. Fixes #78394. Change-Id: I92e04127f275c2394a12d63d2f2a3ce56a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/761161 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2026-03-27runtime/race: use subtests for TestOutputMichael Pratt
For #78394. Change-Id: I4ef1a299f37e2b6532e2008378aca3aa6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/760308 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2026-03-23runtime/race: apply LLVM zero-initialization fixMichael Pratt
Upstream TSAN had bug that could result in use of uninitialized memory on Go threads that don't have any TSAN events. For example, if the thread only ever runs the GC. This bug was fixed upstream in https://github.com/llvm/llvm-project/commit/cdfdb06c9155080ec97d6e4f4dd90b6e7cefb0ca. In https://go.dev/issue/78059 we have reports of actual Go crashes due to this bug. Update the prebuilt race sysos to incorporate this fix. The fix is applied as a single patch on top of the existing LLVM revisions to minimize risk of this CL, making it safe to backport. A later CL can update to a newer version of LLVM. Note that all of the patch files are identical. CL 756620 makes racebuild add a unique patch file for each architecture in the event that some arches need distinct patches. linux-loong64 failed race.bash when building the new syso, though they were just timeouts, perhaps from a slow builder. linux-riscv64 is not updated because its builder is too slow (https://go.dev/issue/78258). linux-ppc64le is not updated because its builder is missing curl (https://go.dev/issue/78210). openbsd-amd64 is not updated because its builder is missing unzip (https://go.dev/issue/78212). netbsd-amd64 is not updated because it does not have a LUCI builder (https://go.dev/issue/61121). Fixes #78059. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-race,gotip-darwin-arm64-race,gotip-darwin-amd64-race,gotip-freebsd-amd64-race,gotip-windows-amd64-race,gotip-linux-s390x-race,gotip-linux-arm64-race,gotip-linux-loong64 Change-Id: I5404cb88af9d86b56b385801f8a9ed106a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/757521 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Bypass: Michael Pratt <mpratt@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>
2025-08-12runtime/race: restore previous version of LLVM TSAN on macOSCherry Mui
Apparently CL 692996 made the Darwin race builders to be very flaky. That CL does two things: 1. uses "ld -r" to strip out the dynamic symbol table; 2. updates to a newer version of LLVM TSAN. To narrow it down, this CL undoes the second part, restpring the previous version of LLVM TSAN, but keeps the "ld -r" part. For #74978. Change-Id: I0611d733232b18440f249cd5a0b76f7e1ff99a55 Reviewed-on: https://go-review.googlesource.com/c/go/+/695137 Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Bypass: Cherry Mui <cherryyz@google.com> Commit-Queue: Cherry Mui <cherryyz@google.com>
2025-08-06runtime/race: update darwin race sysoCherry Mui
On macOS, the script in LLVM TSAN building the race syso files produces the Mach-O object with a malformed dynamic symbol table, which new Apple linker doesn't like and emits an annoying warning (https://github.com/golang/go/issues/61229#issuecomment-1988965927). The dynamic symbol table isn't really needed, as it is a static object. Perhaps it should be fixed in TSAN or the C toolchain, but we can do a simple workaround: pass it through "ld -r", which produces an equivalent object file with LC_DYSYMTAB removed. CL 692975 changes racebuild to do this, which produces new syso's in this CL. While here, build the syso with a newer version of LLVM TSAN. Updates #61229. Change-Id: Ide4b7831eb2cb6877c8ace7b3ec8ff565a9eaf54 Reviewed-on: https://go-review.googlesource.com/c/go/+/692996 Reviewed-by: David Chase <drchase@google.com> TryBot-Bypass: Cherry Mui <cherryyz@google.com>
2025-07-29internal/goexperiment: delete RangeFunc goexperimentCherry Mui
It is now always enabeld. The GOEXPERIMENT doesn't control anything. Remove. Change-Id: I50eb09f4537f90ec28152eb59a5a689127843fce Reviewed-on: https://go-review.googlesource.com/c/go/+/684838 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-14runtime: help the race detector detect possible concurrent cleanupsMichael Anthony Knyszek
This change makes it so that cleanup goroutines, in race mode, create a fake race context and switch to it, emulating cleanups running on new goroutines. This helps in catching races between cleanups that might run concurrently. Change-Id: I4c4e33054313798d4ac4e5d91ff2487ea3eb4b16 Reviewed-on: https://go-review.googlesource.com/c/go/+/652635 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-05-07cmd,runtime: enable race detector on loong64Guoqi Chen
The race feature depends on llvm. And support for building the tsan library on linux/loong64 has been added in this patch [1], which has been merged into the branch main and has landed in llvm18. The support for linux/loong64 in racebuild has been implemented in CL 655775, now racebuild can successfully build race_linux_loong64.syso [2]. [1]: https://github.com/llvm/llvm-project/pull/72819 [2]: racebuild -platforms linux/loong64 -cherrypick 'refs/changes/16/543316/10' \ -rev 83fe85115da9dc25fa270d2ea8140113c8d49670 \ -goroot /home/golang/src/go Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn> Change-Id: If389318215476890295ed771297c6c088cfc84b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/543316 Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn> Reviewed-by: Junyang Shao <shaojunyang@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Meidan Li <limeidan@loongson.cn> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
2025-03-21runtime: fix interactions between synctest, race detector, and timersDamien Neil
When an AfterFunc executes in a synctest bubble, there is a series of happens-before relationships: 1. The AfterFunc is created. 2. The AfterFunc goroutine executes. 3. The AfterFunc goroutine returns. 4. A subsequent synctest.Wait call returns. We were failing to correctly establish the happens-before relationship between the AfterFunc goroutine and the AfterFunc itself being created. When an AfterFunc executes, the G running the timer temporarily switches to the timer heap's racectx. It then calls time.goFunc, which starts a new goroutine to execute the timer. time.goFunc relies on the new goroutine inheriting the racectx of the G running the timer. Normal, non-synctest timers, execute with m.curg == nil, which causes new goroutines to inherit the g0 racectx. We were running synctest timers with m.curg set (to the G executing synctest.Run), so the new AfterFunc goroutine was created using m.curg's racectx. This resulted in us not properly establishing the happens-before relationship between AfterFunc being called and the AfterFunc goroutine starting. Fix this by setting m.curg to nil while executing timers. As one additional fix, when waking a blocked bubble, wake the root goroutine rather than a goroutine blocked in Wait if there is a timer that can fire. Fixes #72750 Change-Id: I2b2d6b0f17f64649409adc93c2603f720494af89 Reviewed-on: https://go-review.googlesource.com/c/go/+/658595 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-03-20runtime/race: fix reversed conditional in test for fatal map accessDamien Neil
Change-Id: Icc4d90355d8af07fdec852b2adf720f7cfd1edd6 Reviewed-on: https://go-review.googlesource.com/c/go/+/659735 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-20runtime/race: don't complain about unrun tests when fatal map access happensDamien Neil
Fixes #72964 Change-Id: I42c6994fec3b21774bddd1d4d65dc832d9149446 Reviewed-on: https://go-review.googlesource.com/c/go/+/659697 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-19runtime/race: detect when TestRace fails to run all tests, skip failuresDamien Neil
TestRace runs a collection of tests, some of which are expected to fail with data races. Make TestRace more robust at detecting when the test run is cut short, such as when a test causes an unhandled panic. Skip TestRaceRangeFuncIterator, which contains an unhandled panic. This test was causing all subsequent tests to not run. Skip TestNoRaceRangeFuncIterator, which contains an unexpected data race. This test was not running due to the above failure. For #72925 Change-Id: Id662375cc498ea25ae308619709768588bf6a2f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/658875 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
2024-11-18runtime: get rid of gc programs for typesKeith Randall
Instead, have the runtime build the gc bitmaps on demand at runtime. Change-Id: If7a245bc62e4bce3ce80972410b0ed307d921abe Reviewed-on: https://go-review.googlesource.com/c/go/+/616255 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@google.com>
2024-11-07runtime/race: treat map concurrent access detection as a race detector hitKeith Randall
Sometimes the runtime realizes there is a race before the race detector does. Maybe that's a bug in the race detector? But we should probably handle it. Update #70164 (Fixes? I'm not sure.) Change-Id: Ie7e8bf2b06701368e0551b4a1aa40f6746bbddd8 Reviewed-on: https://go-review.googlesource.com/c/go/+/626036 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-01cmd/compile: add race instrumentation during walkCompareCuong Manh Le
So the racy usage could be detected after re-writing "==" to runtime.memequal call. Updates #61204 Change-Id: Idb4ac37e55813cc87f9d16aa656fb447edf69ea1 Reviewed-on: https://go-review.googlesource.com/c/go/+/601117 Reviewed-by: Egon Elbre <egonelbre@gmail.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> 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>
2024-07-30cmd/compile: add "deadlocals" pass to remove unused localsDavid Chase
This CL adds a "deadlocals" pass, which runs after inlining and before escape analysis, to prune any unneeded local variables and assignments. In particular, this helps avoid unnecessary Addrtaken markings from unreachable closures. Deadlocals is sensitive to "_ = ..." as a signal of explicit use for testing. This signal occurs only if the entire left-hand-side is "_" targets; if it is `_, ok := someInlinedFunc(args)` then the first return value is eligible for dead code elimination. Use this (`_ = x`) to fix tests broken by deadlocals elimination. Includes a test, based on one of the tests that required modification. Matthew Dempsky wrote this, changing ownership to allow rebases, commits, tweaks. Fixes #65158. Old-Change-Id: I723fb69ccd7baadaae04d415702ce6c8901eaf4e Change-Id: I1f25f4293b19527f305c18c3680b214237a7714c Reviewed-on: https://go-review.googlesource.com/c/go/+/600498 Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: David Chase <drchase@google.com> Commit-Queue: David Chase <drchase@google.com>
2024-07-25runtime: use slices and maps to clean up testsapocelipes
Replace reflect.DeepEqual with slices.Equal/maps.Equal, which is much faster. Also remove some unecessary helper functions. Change-Id: I3e4fa2938fed1598278c9e556cd4fa3b9ed3ad6d GitHub-Last-Rev: 69bb43fc6e5c4a4a7d028528fe00b43db784464e GitHub-Pull-Request: golang/go#67603 Reviewed-on: https://go-review.googlesource.com/c/go/+/587815 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-05-21cmd/compile: for rangefunc, add checks and tests, fix panic interactionsDavid Chase
Modify rangefunc #next protocol to make it more robust Extra-terrible nests of rangefunc iterators caused the prior implementation to misbehave non-locally (in outer loops). Add more rangefunc exit flag tests, parallel and tricky This tests the assertion that a rangefunc iterator running in parallel can trigger the race detector if any of the parallel goroutines attempts an early exit. It also verifies that if everything else is carefully written, that it does NOT trigger the race detector if all the parts run time completion. Another test tries to rerun a yield function within a loop, so that any per-line shared checking would be fooled. Added all the use-of-body/yield-function checking. These checks handle pathological cases that would cause rangefunc for loops to behave in surprising ways (compared to "regular" for loops). For example, a rangefunc iterator might defer-recover a panic thrown in the syntactic body of a loop; this notices the fault and panics with an explanation Modified closure naming to ID rangefunc bodies Add a "-range<N>" suffix to the name of any closure generated for a rangefunc loop body, as provided in Alessandro Arzilli's CL (which is merged into this one). Fix return values for panicky range functions This removes the delayed implementation of "return x" by ensuring that return values (in rangefunc-return-containing functions) always have names and translating the "return x" into "#rv1 = x" where #rv1 is the synthesized name of the first result. Updates #61405. Change-Id: I933299ecce04ceabcf1c0c2de8e610b2ecd1cfd8 Reviewed-on: https://go-review.googlesource.com/c/go/+/584596 Reviewed-by: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Tim King <taking@google.com>
2024-03-08runtime: fix spurious race using Ticker.ResetRuss Cox
Ticker.Reset was added in CL 217362 in 2020. It added the runtime helper modTimer, which is analogous to startTimer and resetTimer but for tickers. Unlike those, it does not contain a racerelease, which means that code synchronizing by starting a ticker will be diagnosed with a spurious race. Add racerelease to modTimer and add tests of all three racereleases (in startTimer, resetTimer, and modTimer). Also do not call time.resetTimer from elsewhere in runtime, since that function is only for package time. Use t.reset instead. For #33184. Change-Id: Ie40c1ad24911f21e81b1d3cc608cf086ff2bc83d Reviewed-on: https://go-review.googlesource.com/c/go/+/568340 Auto-Submit: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2023-11-20runtime/race: update race syso for PPC64LECherry Mui
Following CL 543035, this CL updates race syso for Linux/PPC64LE. Now we have update all of them (except OpenBSD). For #61395. Fixes #62624. Change-Id: I9e1d758355114a50ff206e5d78dc4ea8a06367d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/543397 Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-16runtime/race: update race syso files to support atomic And, OrCherry Mui
TSAN recently got support for Go's new atomic And and Or operations (#61395). This CL updates the race syso files to include the change. Also regenerate cgo dynamic imports on darwin. OpenBSD/AMD64 is not updated, as TSAN no longer supports OpenBSD (#52090). Linux/PPC64 is not updated, as I'm running into some builder issues. Still working on it. For #61395. For #62624. Change-Id: Ifc90ea79284f29a356f9e8a5f144f6c690881395 Reviewed-on: https://go-review.googlesource.com/c/go/+/543035 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
2023-10-25testing: use monotonic counts to attribute races in subtestsBryan C. Mills
This implements the approach I described in https://go-review.git.corp.google.com/c/go/+/494057/1#message-5c9773bded2f89b4058848cb036b860aa6716de3. Specifically: - Each level of test atomically records the cumulative number of races seen as of the last race-induced test failure. - When a subtest fails, it logs the race error, and then updates its parents' counters so that they will not log the same error. - We check each test or benchmark for races before it starts running each of its subtests or sub-benchmark, before unblocking parallel subtests, and after running any cleanup functions. With this implementation, it should be the case that every test that is running when a race is detected reports that race, and any race reported for a subtest is not redundantly reported for its parent. The regression tests are based on those added in CL 494057 and CL 501895, with a few additions based on my own review of the code. Fixes #60083. Change-Id: I578ae929f192a7a951b31b17ecb560cbbf1ef7a1 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-amd64-longtest-race,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/506300 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-08-17cmd/compile/internal/typecheck: normalize go/defer statements earlierMatthew Dempsky
Normalizing go/defer statements to always use functions with zero parameters and zero results was added to escape analysis, because that was the earliest point at which all three frontends converged. Now that we only have the unified frontend, we can do it during typecheck, which is where we perform all other desugaring and normalization rewrites. Change-Id: Iebf7679b117fd78b1dffee2974bbf85ebc923b23 Reviewed-on: https://go-review.googlesource.com/c/go/+/520260 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-07-18all: fix typosJes Cok
Change-Id: I510b0a4bf3472d937393800dd57472c30beef329 GitHub-Last-Rev: 8d289b73a37bd86080936423d981d21e152aaa33 GitHub-Pull-Request: golang/go#60960 Reviewed-on: https://go-review.googlesource.com/c/go/+/505398 Auto-Submit: Robert Findley <rfindley@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-06-23runtime: set raceignore to zero when starting a new goroutineJelle van den Hooff
When reusing a g struct the runtime did not reset g.raceignore. Initialize raceignore to zero when initially setting racectx. A goroutine can end with a non-zero raceignore if it exits after calling runtime.RaceDisable without a matching runtime.RaceEnable. If that goroutine's g is later reused the race detector is in a weird state: the underlying g.racectx is active, yet g.raceignore is non-zero, and raceacquire/racerelease which check g.raceignore become no-ops. This causes the race detector to report races when there are none. Fixes #60934 Change-Id: Ib8e412f11badbaf69a480f03740da70891f4093f Reviewed-on: https://go-review.googlesource.com/c/go/+/505055 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Knyszek <mknyszek@google.com>
2023-06-16runtime: use 1-byte load for address checking in racecallatomicCherry Mui
In racecallatomic, we do a load before calling into TSAN, so if the address is invalid we fault on the Go stack. We currently use a 8-byte load instruction, regardless of the data size that the atomic operation is performed on. So if, say, we are doing a LoadUint32 at an address that is the last 4 bytes of a memory mapping, we may fault unexpectedly. Do a 1-byte load instead. (Ideally we should do a load with the right size, so we fault correctly if we're given an unaligned address for a wide load across a page boundary. Leave that for another CL.) Fix AMD64, ARM64, and PPC64. The code already uses 1-byte load on S390X. Should fix #60825. Change-Id: I3dee93eb08ba180c85e86a9d2e71b5b520e8dcf0 Reviewed-on: https://go-review.googlesource.com/c/go/+/503937 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: David Chase <drchase@google.com>
2023-05-23runtime: symbolize wrappers as a last resort in race tracebacksAustin Clements
CL 466099 rewrote stack symbolization in race reports. Prior to this CL, physical frames consisting entirely of wrapper logical frame would print the wrapper, even though in other cases we try to avoid printing wrappers. CL 466099 unintentionally changed this behavior and now physical frames consisting entirely of wrapper frames instead fail to symbolize and print "??()". Fix this by taking the outermost wrapper frame if the entire logical frame expansion consists of wrappers. Fixes #60245. Change-Id: I13de8857e508b757ea10d1fc7a47258d7fddbfdb Reviewed-on: https://go-review.googlesource.com/c/go/+/497235 Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Austin Clements <austin@google.com> Auto-Submit: Austin Clements <austin@google.com>
2023-03-06cmd/compile: experimental loop iterator capture semantics changeDavid Chase
Adds: GOEXPERIMENT=loopvar (expected way of invoking) -d=loopvar={-1,0,1,2,11,12} (for per-package control and/or logging) -d=loopvarhash=... (for hash debugging) loopvar=11,12 are for testing, benchmarking, and debugging. If enabled,for loops of the form `for x,y := range thing`, if x and/or y are addressed or captured by a closure, are transformed by renaming x/y to a temporary and prepending an assignment to the body of the loop x := tmp_x. This changes the loop semantics by making each iteration's instance of x be distinct from the others (currently they are all aliased, and when this matters, it is almost always a bug). 3-range with captured iteration variables are also transformed, though it is a more complex transformation. "Optimized" to do a simpler transformation for 3-clause for where the increment is empty. (Prior optimization of address-taking under Return disabled, because it was incorrect; returns can have loops for children. Restored in a later CL.) Includes support for -d=loopvarhash=<binary string> intended for use with hash search and GOCOMPILEDEBUG=loopvarhash=<binary string> (use `gossahash -e loopvarhash command-that-fails`). Minor feature upgrades to hash-triggered features; clients can specify that file-position hashes use only the most-inline position, and/or that they use only the basenames of source files (not the full directory path). Most-inlined is the right choice for debugging loop-iteration change once the semantics are linked to the package across inlining; basename-only makes it tractable to write tests (which, otherwise, depend on the full pathname of the source file and thus vary). Updates #57969. Change-Id: I180a51a3f8d4173f6210c861f10de23de8a1b1db Reviewed-on: https://go-review.googlesource.com/c/go/+/411904 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-25runtime/race: update race_windows_amd64.sysoThan McIntosh
Update race_windows_amd64.syso to latest tsan (V3) runtime. This version of the runtime depends on libsynchronization.a, so to use this syso, you need to also be using a sufficiently up to date version of GCC (notably GCC 5.1, installed on the Go windows builders right now, does not include this library). Updates #48231. Updates #35006. Fixes #49761. Change-Id: Ia1e2b1d8fe7e2c99728150734935a2c522006caa Reviewed-on: https://go-review.googlesource.com/c/go/+/420197 Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-22runtime/race: add build tag to internal amd64vN packagesCherry Mui
Only one of the runtime/race/internal/amd64vN packages should be included in a build. Generally this is true because the runtime/race package would import only one of them depending on the build configuration. But for "go install -buildmode=shared std" it includes all Go packages in std, which includes both, which then causes link-time failure due to duplicated symbols. To avoid this, we add build tags to the internal packages, so, depending on the build configuation, only one package would contain buildable go files therefore be included in the build. For #57334. Change-Id: I52ddc3a40e16c7d04b4dd861e9689918d27e8509 Reviewed-on: https://go-review.googlesource.com/c/go/+/458695 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-11-16runtime/race: do not use cgo on macOSRuss Cox
The use of an empty import "C" to trigger cgo in runtime/race serves two purposes: 1. Cause the runtime to use the C library to create system threads, because the race syso implementation expects things like thread-local storage to work correctly. 2. Derive the right set of //go:cgo_import_dynamic comments to pass to the Go linker, so that it doesn't diagnose them as undefined references. On macOS, (1) is unnecessary because using the C library (via DLL calls) is the only way the runtime ever creates threads. We can accomplish (2) by writing those comments ourselves. Having done that in this CL, cgo is no longer needed to run the race detector on macOS, which means that having a pre-compiled set of .a files is no longer necessary, nor is having Xcode for use with cgo when rebuilding those .a files. Change-Id: Iee24cc67900eb542141b32beaadafb2c94f5fe26 Reviewed-on: https://go-review.googlesource.com/c/go/+/451055 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-11-11runtime/race: add missing copyright headers to syso import filesBryan C. Mills
These were apparently missed in CL 424034. Change-Id: I60fcdd8c16992177a23c0e701f4224b250cfabee Reviewed-on: https://go-review.googlesource.com/c/go/+/449855 Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
2022-10-21runtime/race: add GOAMD64=v3 version of linux race .sysoKeith Randall
Makes -race mode faster, in the 15% speedup range. Update #53743 Change-Id: I735eb71902b41c924c9f885ded8f7a350a56b751 Reviewed-on: https://go-review.googlesource.com/c/go/+/444396 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2022-09-15runtime/race: introduce subarch versioning of race sysoKeith Randall
Allow us to select a race .syso file based on subarch values. Note that this doesn't actually change the syso used. This CL just moves things around in preparation for adding v3-specific versions in future CLs. Change-Id: I14e3c273a7c6f07b13b22193b7a851ea94c765cb Reviewed-on: https://go-review.googlesource.com/c/go/+/424034 Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Keith Randall <khr@golang.org>
2022-09-09runtime/race: also unmap memory if TestNonGoMemory failsTobias Klauser
Change-Id: I7ea150e4896fc9b2e3a6dbdd9a1c2b651e74b844 Reviewed-on: https://go-review.googlesource.com/c/go/+/428778 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-08runtime/race: use strings.Buildercuiweixie
Change-Id: I644f696d00b5bce448e0a00835b3162f5203f346 Reviewed-on: https://go-review.googlesource.com/c/go/+/428278 Auto-Submit: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-07-11runtime/race: update amd64 syso images to avoid sse4Than McIntosh
Rebuild selected amd64 syso images with updated LLVM build rules that avoid the use of SSE4, so as to ensure that the Go race detector continues to work on older x86 cpus. No changes to the syso files for openbsd/amd64 (upstream support has been removed in LLVM) or netbsd/amd64 (work still in progress there). Fixes #53743. Change-Id: I738ae4d1e0528c6e06dd4ddb78e7039a30a51779 Reviewed-on: https://go-review.googlesource.com/c/go/+/416857 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Than McIntosh <thanm@google.com>
2022-05-04cmd,runtime: enable race detector on s390xIlya Leoshkevich
LLVM has SystemZ ThreadSanitizer support now [1], this patch integrates it with golang. The biggest part is the glue code in race_s390x.s, which is derived from race_arm64.s, and then the support needs to be enabled in four places. [1] https://reviews.llvm.org/D105629 Change-Id: I1d4e51beb4042603b681e4aca9af6072879d54d6 Reviewed-on: https://go-review.googlesource.com/c/go/+/336549 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Keith Randall <khr@golang.org>
2022-04-27[dev.boringcrypto] all: merge master into dev.boringcryptoChressie Himpel
Change-Id: Ic5f71c04f08c03319c043f35be501875adb0a3b0
2022-04-22runtime/race: add s390x .syso fileKeith Randall
Built using racebuild. Note that racebuild fails when trying to test the .syso, because the Go runtime doesn't think we support s390x race yet. But it builds the .syso as a side effect which I grabbed. There's something of a chicken-and-egg bootstrapping problem here, unfortunately. Change-Id: Ibc6d04fd3a9bfb3224d08e8b78dcf09bb139a59d Reviewed-on: https://go-review.googlesource.com/c/go/+/401714 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Jonathan Albrecht <jonathan.albrecht@ibm.com>
2022-04-05[dev.boringcrypto] all: merge master into dev.boringcryptoLasse Folger
Change-Id: Iaf618444dd2d99721c19708df9ce2c1f35854efd
2022-04-04runtime/race: update PPC64LE syso file to new TSAN runtime (v3)Cherry Mui
In CL 397494 Linux/PPC64LE syso was not updated due to test failure. It should be fixed by the previous CL and should work now. Change-Id: Ieb0993ded5541397094d3aecae28c5255c822eac Reviewed-on: https://go-review.googlesource.com/c/go/+/397676 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2022-04-01runtime/race: update syso files to new TSAN runtime (v3)Cherry Mui
Following CL 333529, update syso files for other architectures. Windows/AMD64 is not updated, waiting for Than for C toolchain updates. OpenBSD/AMD64 is not updated as upstream LLVM TSAN removed OpenBSD support (#52090). Linux/PPC64LE is not updated due to a test failure. Will look into it. Change-Id: I46441fd3bb0f2c9e372d3e7fd43744ffafaf87a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/397494 Trust: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2022-03-29[dev.boringcrypto] all: merge master into dev.boringcryptoNicolas Hillegeer
Change-Id: I04d511ed8e3e7ca4a3267f226a0c3e248c0f84a9
2022-03-28runtime/race: update runtime (v3)Dmitry Vyukov
New tsan runtime (v3) built on llvm commit 1784fe0532a6. The new runtime features: - 2x smaller shadow memory (2x of app memory) - faster fully vectorized (on x86) race detection - small fixed-size vector clocks (512b) - fast vectorized vector clock operations - unlimited number of alive threads/goroutines Some random subset of benchmarks: encoding/json: CodeEncoder-72 20.3ms ± 6% 11.7ms ± 4% -42.02% (p=0.000 n=10+8) CodeMarshal-72 22.3ms ±11% 12.7ms ±11% -43.28% (p=0.000 n=10+10) CodeDecoder-72 46.1ms ±42% 20.2ms ± 7% -56.18% (p=0.000 n=10+10) CodeUnmarshal-72 16.7ms ±14% 13.2ms ± 9% -20.93% (p=0.000 n=10+10) CodeUnmarshalReuse-72 17.7ms ±17% 12.8ms ± 8% -27.58% (p=0.000 n=10+10) net/http: ClientServerParallel4-72 914µs ±18% 72µs ± 5% -92.16% (p=0.000 n=20+18) ClientServerParallel64-72 1.77ms ±16% 0.12ms ±29% -93.43% (p=0.000 n=20+17) ClientServerParallelTLS4-72 1.99ms ±33% 0.20ms ± 5% -89.83% (p=0.000 n=19+17) ClientServerParallelTLS64-72 2.72ms ±26% 0.25ms ±16% -90.96% (p=0.000 n=20+16) compress/flate: Decode/Digits/Huffman/1e4-72 2.53ms ± 3% 1.47ms ± 4% -41.72% (p=0.000 n=9+10) Decode/Digits/Speed/1e4-72 2.59ms ± 5% 1.52ms ± 3% -41.44% (p=0.000 n=8+9) Decode/Digits/Default/1e4-72 2.56ms ± 6% 1.51ms ± 4% -40.96% (p=0.000 n=10+10) Decode/Digits/Compression/1e4-72 2.54ms ± 6% 1.52ms ± 2% -40.14% (p=0.000 n=10+9) Decode/Newton/Huffman/1e4-72 2.65ms ± 3% 1.58ms ± 4% -40.45% (p=0.000 n=10+10) Decode/Newton/Speed/1e4-72 2.16ms ± 9% 1.28ms ± 5% -40.59% (p=0.000 n=10+10) Decode/Newton/Default/1e4-72 2.01ms ± 8% 1.16ms ± 6% -42.11% (p=0.000 n=10+10) Decode/Newton/Compression/1e4-72 1.99ms ± 6% 1.17ms ± 3% -41.05% (p=0.000 n=9+10) Encode/Digits/Huffman/1e4-72 2.05ms ± 2% 0.75ms ± 5% -63.32% (p=0.000 n=10+10) Encode/Digits/Speed/1e4-72 2.89ms ± 2% 1.37ms ± 2% -52.56% (p=0.000 n=9+10) Encode/Digits/Default/1e4-72 7.55ms ± 2% 3.86ms ± 4% -48.93% (p=0.000 n=8+10) Encode/Digits/Compression/1e4-72 7.46ms ± 4% 3.88ms ± 4% -48.07% (p=0.000 n=9+9) Encode/Newton/Huffman/1e4-72 2.20ms ± 4% 0.90ms ± 6% -59.01% (p=0.000 n=10+10) Encode/Newton/Speed/1e4-72 2.62ms ± 2% 1.30ms ± 4% -50.52% (p=0.000 n=9+10) Encode/Newton/Default/1e4-72 7.40ms ± 5% 3.72ms ± 2% -49.65% (p=0.000 n=10+9) Encode/Newton/Compression/1e4-72 7.67ms ± 9% 3.85ms ± 4% -49.87% (p=0.000 n=10+10) encoding/json short tests: Time 2.34sec ± 6% 1.67sec ±11% -28.85% (p=0.000 n=10+10) Memory 266MB ± 1% 190MB ± 9% -28.78% (p=0.000 n=10+10) compress/flate short tests: Time 4.69sec ± 4% 2.78sec ± 3% -40.61% (p=0.000 n=10+10) Memory 284MB ± 5% 181MB ± 4% -36.04% (p=0.000 n=10+9) sync short tests: Time 4.87sec ± 4% 0.87sec ± 6% -82.21% (p=0.000 n=10+10) Memory 147MB ± 3% 99MB ± 8% -32.47% (p=0.000 n=10+9) Fixes #47056 Fixes #38184 Change-Id: I0cf228f2e4cac7778d34d33e46df7c081645f5d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/333529 Run-TryBot: Dmitry Vyukov <dvyukov@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Trust: Dmitry Vyukov <dvyukov@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-03-12syscall: add race annotations to Pread and PwriteIan Lance Taylor
Fixes #51618 Change-Id: Ife894d8c313dce8c4929f40fa0ac90a069f77a89 Reviewed-on: https://go-review.googlesource.com/c/go/+/391954 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2022-02-03[dev.boringcrypto] all: merge master into dev.boringcryptoChressie Himpel
Change-Id: I18dbf4f9fa7e2334fccedd862a523126cf38164e
2022-01-14runtime/race: be less picky about test run timeAustin Clements
Currently, there are two regexps in the race detector output tests that assume subtests will complete in < 1 second. This isn't necessary and very occasionally fails (on builders that are probably very loaded). Make these tests less picky about timing. Fixes #50612. Change-Id: Ib3f94d6c5dc37541dbeb06de71cf462a74af844b Reviewed-on: https://go-review.googlesource.com/c/go/+/378581 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-13all: gofmt -w -r 'interface{} -> any' srcRuss Cox
And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>