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

sync/atomic, cmd/compile: stack corruption with AddUint32 #16985

Closed
iangudger opened this issue Sep 4, 2016 · 2 comments
Closed

sync/atomic, cmd/compile: stack corruption with AddUint32 #16985

iangudger opened this issue Sep 4, 2016 · 2 comments
Milestone

Comments

@iangudger
Copy link
Contributor

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

devel +fd41951

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

AMD64 Linux

What did you do?

Compile and run this program:

package main

import "sync/atomic"

var count uint32

func main() {
    buffer := []byte("T")
    for i := 0; i < len(buffer); {
        atomic.AddUint32(&count, 1)
        _ = buffer[i]
        i++
        i++
    }
}

What did you expect to see?

No output. This is what happens in Go 1.7.

What did you see instead?

panic: runtime error: index out of range

goroutine 1 [running]:
panic(0x458f40, 0xc42000a150)
    /go/src/runtime/panic.go:500 +0x1a0
main.main()
    inc_panic_example/main.go:11 +0x76
@dsnet dsnet added this to the Go1.8 milestone Sep 4, 2016
@dsnet
Copy link
Member

dsnet commented Sep 4, 2016

Nice. Thanks for the report.

Git bisect reports the cause as d6098e4.
/cc @randall77 @cherrymui

@josharian josharian changed the title sync/atomic: stack curruption sync/atomic, cmd/compile: stack corruption with AddUint32 Sep 5, 2016
@gopherbot
Copy link

CL https://golang.org/cl/28510 mentions this issue.

gopherbot pushed a commit that referenced this issue Sep 6, 2016
It should alias to Xchg instead of Swap. Found when testing #16985.

Change-Id: If9fd734a1f89b8b2656f421eb31b9d1b0d95a49f
Reviewed-on: https://go-review.googlesource.com/28512
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
@golang golang locked and limited conversation to collaborators Sep 6, 2017
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

4 participants