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

"checkptr: unsafe pointer arithmetic" when using go race detector #28

Closed
chrbsg opened this issue Jul 6, 2020 · 1 comment
Closed

Comments

@chrbsg
Copy link

chrbsg commented Jul 6, 2020

Looks like some issue with uintptr when creating an Opus stream. Code does:

        r := bytes.NewReader(resp.AudioContent)
        s, err := opus.NewStream(r)
$ go build -race && ./run

fatal error: checkptr: unsafe pointer arithmetic

goroutine 230 [running]:
runtime.throw(0x12d4205, 0x23)
	/usr/local/go/src/runtime/panic.go:1116 +0x72 fp=0xc000519ae8 sp=0xc000519ab8 pc=0x4473d2
runtime.checkptrArithmetic(0x1, 0x0, 0x0, 0x0)
	/usr/local/go/src/runtime/checkptr.go:26 +0xce fp=0xc000519b18 sp=0xc000519ae8 pc=0x41a2ee
gopkg.in/hraban/opus%2ev2.(*Stream).Init.func1(0xc000498880, 0xc00037b1c8, 0x1)
	/home/chrb/go/pkg/mod/gopkg.in/hraban/[email protected]/stream.go:108 +0x66 fp=0xc000519b70 sp=0xc000519b18 pc=0xe256b6
gopkg.in/hraban/opus%2ev2.(*Stream).Init(0xc000498880, 0x15f9060, 0xc00071d230, 0x0, 0x0)
	/home/chrb/go/pkg/mod/gopkg.in/hraban/[email protected]/stream.go:112 +0x277 fp=0xc000519c40 sp=0xc000519b70 pc=0xe237d7
gopkg.in/hraban/opus%2ev2.NewStream(0x15f9060, 0xc00071d230, 0xc0000a7bf0, 0xc000502740, 0x0)
	/home/chrb/go/pkg/mod/gopkg.in/hraban/[email protected]/stream.go:75 +0xa0 fp=0xc000519c90 sp=0xc000519c40 pc=0xe234c0
main.sayGoogle(0xc0000198e0, 0x14, 0xc00031e4a0, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/chrb/go/src/x/main.go:310 +0x568 fp=0xc000519e58 sp=0xc000519c90 pc=0x105a948
main.speak(0xc0000198e0, 0x14, 0xc000472000, 0xc0004a5a40)
	/home/chrb/go/src/x/main.go:488 +0x166 fp=0xc000519f70 sp=0xc000519e58 pc=0x105cf36
main.handleIncomingAudio.func4(0xc000472000, 0xc0004a5a40, 0xc0003074e0)
	/home/chrb/go/src/x/main.go:967 +0xeb fp=0xc000519fc8 sp=0xc000519f70 pc=0x10773bb
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc000519fd0 sp=0xc000519fc8 pc=0x4792f1
created by main.handleIncomingAudio
	/home/chrb/go/src/x/main.go:962 +0x281
@hraban
Copy link
Owner

hraban commented Jul 6, 2020

very interesting. I think I did test this with race and I don't remember this, but googling for the issue and the offending line suggests it might be related to: etcd-io/bbolt#187 . in the line the race detector balks at here, I cast a regular int to a pointer (because of cgo limitations and the opus api), but according to that ticket you're not allowed to have pointers unaligned at word boundaries. the good news is, from my recollection without delving in further, that value iirc is opaque to libopus and only dereferenced by the callback, which doesn't actually dereference it but cast it back to a regular int. the bad news is I don't know if that's true so I'll have to check on this when I have a moment :)

thanks for reporting.

@hraban hraban closed this as completed in 2a2b57e Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants