For cgo callbacks, currently cgocallbackg locks the OS thread and then call cgocallbackg1, which invokes the actual callback, and then unlocks the OS thread in a deferred call. cgocallback then continues assuming we are on the same M. This assumes there is no preemption point between the deferred unlockOSThread and returning to the caller (cgocallbackg). But this is not always true. E.g. when open defer is not used (e.g. PIE or shared build mode on 386), there is a preemption point in deferreturn after invoking the deferred function (when it checks whether there are still defers to run). Instead of relying on and requiring the defer implementation has no preemption point, we move the unlockOSThread to the caller, and ensuring no preemption by setting incgo to true before unlocking. This doesn't cover the panicking path, so we also adds an unlockOSThread there. There we don't need to worry about preemption, because we're panicking out of the callback and we have unwound the g0 stack, instead of reentering cgo. Fixes #62102. Change-Id: I0e0b9f9091be88d01675c0acb7339b81402545be Reviewed-on: https://go-review.googlesource.com/c/go/+/532615 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> |
||
|---|---|---|
| .github | ||
| api | ||
| doc | ||
| lib/time | ||
| misc | ||
| src | ||
| test | ||
| .gitattributes | ||
| .gitignore | ||
| CONTRIBUTING.md | ||
| LICENSE | ||
| PATENTS | ||
| README.md | ||
| SECURITY.md | ||
| codereview.cfg | ||
| go.env | ||
README.md
The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 4.0 Attributions license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Download and Install
Binary Distributions
Official binary distributions are available at https://go.dev/dl/.
After downloading a binary release, visit https://go.dev/doc/install for installation instructions.
Install From Source
If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.
Contributing
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.