Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: Is it necessary to use atomic.Loaduintptr on gp.stackguard0? #37880

Closed
jerome-tan opened this issue Mar 16, 2020 · 1 comment
Closed

Comments

@jerome-tan
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.13.3 linux/amd64

Does this issue reproduce with the latest release?

It's not an issue, just curiosity.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

Reading the source code of runtime.

What did you expect to see?

Read/write operation on gp.stackguard0 does not require any atomic operations.

What did you see instead?

Atomic operations on gp.stackguard0 are used in only one place: runtime/stack.go.

func newstack() {
    ... ...
    // NOTE: stackguard0 may change underfoot, if another thread
    // is about to try to preempt gp. Read it just once and use that same
    // value now and below.
    preempt := atomic.Loaduintptr(&gp.stackguard0) == stackPreempt
    ... ...
}

If there is a data race, why not all use atomic operations?

@cagedmantis
Copy link
Contributor

For asking questions about learning the language, see one of our forums: https://golang.org/wiki/Questions. We only use this issue tracker for tracking bugs. People in the forums can explain what is happening here.

@golang golang locked and limited conversation to collaborators Mar 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants