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: AddUint64 panic on windows/386 #5278

Closed
syndtr opened this issue Apr 12, 2013 · 3 comments
Closed

sync/atomic: AddUint64 panic on windows/386 #5278

syndtr opened this issue Apr 12, 2013 · 3 comments

Comments

@syndtr
Copy link

syndtr commented Apr 12, 2013

What steps will reproduce the problem?

run this http://play.golang.org/p/0dDl9sr7_R on windows/386

What is the expected output?

didn't panic

What do you see instead?

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x4171ac]

goroutine 1 [running]:
sync/atomic.AddUint64()
        C:/Go/src/pkg/sync/atomic/asm_386.s:69 +0xc
main.main()
        C:/Users/Syndtr/testatom/main.go:15 +0x45

goroutine 2 [runnable]:
exit status 2

Which compiler are you using (5g, 6g, 8g, gccgo)?

8g

Which operating system are you using?

windows

Which version are you using?  (run 'go version')

go version devel +d58997478ec6 Mon Apr 08 00:09:35 2013 -0700 windows/386


This only happen if struct contains unsafe.Pointer field.
@minux
Copy link
Member

minux commented Apr 12, 2013

Comment 1:

The caller of 64-bit atomic operation must make sure the
pointer address is aligned to 8-byte boundary.
http://play.golang.org/p/fRMRT2Jzsh
Quote BUGS section of docs for sync/atomic:
BUGS
   On x86-32, the 64-bit functions use instructions unavailable before the
   Pentium MMX. On both ARM and x86-32, it is the caller's responsibility to
   arrange for 64-bit alignment of 64-bit words accessed atomically. The
   first word in a global variable or in an allocated struct or slice can be
   relied upon to be 64-bit aligned.

Status changed to WorkingAsIntended.

@syndtr
Copy link
Author

syndtr commented Apr 12, 2013

Comment 2:

Ah, I see. My bad, sorry.

@remyoudompheng
Copy link
Contributor

Comment 3:

Issue #6674 has been merged into this issue.

This issue was closed.
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