Skip to content

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

Closed
@jonathaningram

Description

@jonathaningram

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

gl.VertexAttribPointer(texCoordAttrib, 2, gl.FLOAT, false, 5*4, gl.PtrOffset(3*4))

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions