go-gl / example

Example programs for the various go-gl packages.
MIT License
223 stars 59 forks source link

fatal error: checkptr: unsafe pointer arithmetic on Go 1.14rc1 #72

Closed jonathaningram closed 3 years ago

jonathaningram commented 4 years ago

Testing Go 1.14rc1 and building the examples with -race panics as below. This is caused by a new checker in 1.14 as described in https://tip.golang.org/doc/go1.14#compiler.

$ # checkout repo
$ cd gl41core-cube
$ go1.14rc1 build -race
$ ./gl41core-cube 
OpenGL version 4.1 INTEL-12.10.16
fatal error: checkptr: unsafe pointer arithmetic
goroutine 1 [running, locked to thread]:
runtime.throw(0x423c365, 0x23)
    /Users/me/sdk/go1.14rc1/src/runtime/panic.go:1112 +0x72 fp=0xc00014fc60 sp=0xc00014fc30 pc=0x4031f32
runtime.checkptrArithmetic(0xc, 0x0, 0x0, 0x0)
    /Users/me/sdk/go1.14rc1/src/runtime/checkptr.go:24 +0xce fp=0xc00014fc90 sp=0xc00014fc60 pc=0x40085ee
github.com/go-gl/gl/v4.1-core/gl.PtrOffset(...)
    /Users/me/go/src/github.com/go-gl/gl/v4.1-core/gl/conversions.go:55
main.main()
    /tmp/go-gl/example/gl41core-cube/cube.go:103 +0x110a fp=0xc00014ff88 sp=0xc00014fc90 pc=0x41656da
runtime.main()
    /Users/me/sdk/go1.14rc1/src/runtime/proc.go:203 +0x212 fp=0xc00014ffe0 sp=0xc00014ff88 pc=0x4034582
runtime.goexit()
    /Users/me/sdk/go1.14rc1/src/runtime/asm_amd64.s:1375 +0x1 fp=0xc00014ffe8 sp=0xc00014ffe0 pc=0x40606f1

https://github.com/go-gl/example/blob/c307114f34620805d657867cb1402769d0c6edd5/gl41core-cube/cube.go#L104

I only had a quick glance at the pointer arithmetic but at a glance it wasn't obvious to me what the fix should be.

Orginally posted in the Gophers Slack channel. cc @dmitshur

pwaller commented 4 years ago

Sounds like a possible duplicate of https://github.com/go-gl/gl/issues/80?