Checkptr=0

410 views
Skip to first unread message

stephen.t....@gmail.com

unread,
Mar 23, 2021, 12:41:02 PM3/23/21
to golang-dev
Hello,

I'm following the latest changes on the development tree and have noticed that the compiler flag "checkptr=0" is currently not having any effect. Has this flag been deprecated or is this just a temporary problem?

Currently, this flag is required when race checking software that uses go-gl. https://github.com/go-gl/gl/issues/124

Regards

Stephen Illingworth


Ian Lance Taylor

unread,
Mar 23, 2021, 2:54:42 PM3/23/21
to stephen.t....@gmail.com, golang-dev
I don't think anything has intentionally changed in this area. Can
you give an example of how the behavior has changed? Thanks.

Ian

stephen.t....@gmail.com

unread,
Mar 23, 2021, 3:45:04 PM3/23/21
to golang-dev
On Tuesday, March 23, 2021 at 6:54:42 PM UTC Ian Lance Taylor wrote:
 
I don't think anything has intentionally changed in this area. Can
you give an example of how the behavior has changed? Thanks.

Running the race detector will turn on the checkptr check. Which is good but will result in a
panic in projects that convert uintptr to unsafe.Pointer in a suspicious manner. An example
of such a project is go-gl.

If we still want to run the race check  we can get around the problem by turning off checkptr:

    go run -race -gcflags=all=-d=checkptr=0 .

If we don't turn it off, we see a panic:

    fatal error: checkptr: pointer arithmetic computed bad pointer value

We see this in every version of Go since checkptr was introduced. This is fine and exactly
the behaviour we would expect.


However, in the current development tree. Setting checkptr=0 has no effect and we see the same panic as we
would if we didn't turn off the check. In other words,

    go run -race .

is the same as

    go run -race -gcflags=all=-d=checkptr=0 .


The simplest reproducible example I know of is the imgui-go-examples project:


From the "cmd/example_sdl_opengl3" directory:

    go run -race -gcflags=all=-d=checkptr=0 -tags='sdl' .

will cause the panic when using the development compiler but not when using 1.16 etc.


Stephen

Ian Lance Taylor

unread,
Mar 23, 2021, 6:28:07 PM3/23/21
to stephen.t....@gmail.com, golang-dev
Thanks. I sent https://golang.org/cl/304253 to fix this.

Ian
Reply all
Reply to author
Forward
0 new messages