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

race detector: fatal error: checkptr: pointer arithmetic computed bad pointer value #1957

Closed
tehsphinx opened this issue Feb 14, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@tehsphinx
Copy link
Contributor

Describe the bug:

Starting an application with go run --race . crashes with the following error at startup:

fatal error: checkptr: pointer arithmetic computed bad pointer value

goroutine 40 [running, locked to thread]:
runtime.throw(0x4601533, 0x37)
/usr/local/go/src/runtime/panic.go:1116 +0x72 fp=0xc000629538 sp=0xc000629508 pc=0x403b9b2
runtime.checkptrArithmetic(0xc, 0x0, 0x0, 0x0)
/usr/local/go/src/runtime/checkptr.go:26 +0xd7 fp=0xc000629568 sp=0xc000629538 pc=0x400d1f7
github.com/go-gl/gl/v3.2-core/gl.PtrOffset(...)
/Users/user/go/pkg/mod/github.com/go-gl/[email protected]/v3.2-core/gl/conversions.go:55
fyne.io/fyne/v2/internal/painter/gl.(*glPainter).glCreateBuffer(0xc000606000, 0xc000026050, 0x14, 0x14, 0x0)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/gl/gl_core.go:219 +0x409 fp=0xc000629608 sp=0xc000629568 pc=0x43f2f29
fyne.io/fyne/v2/internal/painter/gl.(*glPainter).drawTextureWithDetails(0xc000606000, 0x46726c0, 0xc0002e42a0, 0xc0006296e8, 0x4140000041000000, 0x41a8000042ee0000, 0x43fa000044480000, 0x0, 0x3f800000)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/gl/draw.go:27 +0x152 fp=0xc000629668 sp=0xc000629608 pc=0x43ee272
fyne.io/fyne/v2/internal/painter/gl.(*glPainter).drawText(0xc000606000, 0xc0002e42a0, 0x4140000041000000, 0x43fa000044480000)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/gl/draw.go:78 +0x357 fp=0xc000629708 sp=0xc000629668 pc=0x43ef057
fyne.io/fyne/v2/internal/painter/gl.(*glPainter).drawObject(0xc000606000, 0x46726c0, 0xc0002e42a0, 0x4140000041000000, 0x43fa000044480000)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/gl/draw.go:97 +0x3d1 fp=0xc000629758 sp=0xc000629708 pc=0x43ef591
fyne.io/fyne/v2/internal/painter/gl.(*glPainter).Paint(0xc000606000, 0x46726c0, 0xc0002e42a0, 0x4140000041000000, 0x43fa000044480000)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/painter/gl/painter.go:70 +0xab fp=0xc000629790 sp=0xc000629758 pc=0x43f392b
fyne.io/fyne/v2/internal/driver/glfw.(*glCanvas).paint.func1(0xc000622080, 0x4140000041000000)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/canvas.go:435 +0x138 fp=0xc000629818 sp=0xc000629790 pc=0x4451698
fyne.io/fyne/v2/internal/driver/glfw.(*glCanvas).walkTree.func1(0x46726c0, 0xc0002e42a0, 0x4140000041000000, 0x0, 0x4f0000004f000000, 0xc000629d00)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/canvas.go:516 +0x1e2 fp=0xc000629888 sp=0xc000629818 pc=0x4451e02
fyne.io/fyne/v2/internal/driver.walkObjectTree(0x46726c0, 0xc0002e42a0, 0x4080000040800000, 0x4672ba0, 0xc0001483f0, 0x4080000040800000, 0x0, 0x4f0000004f000000, 0xc000629cc8, 0xc000629ca0, ...)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/util.go:169 +0x593 fp=0xc000629948 sp=0xc000629888 pc=0x4277893
fyne.io/fyne/v2/internal/driver.walkObjectTree.func1(...)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/util.go:176
fyne.io/fyne/v2/internal/driver.walkObjectTree(0x4672ba0, 0xc0001483f0, 0x4080000040800000, 0x46723c0, 0xc00014c6c0, 0x4080000040800000, 0x0, 0x4f0000004f000000, 0xc000629cc8, 0xc000629ca0, ...)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/util.go:190 +0x4f0 fp=0xc000629a08 sp=0xc000629948 pc=0x42777f0
fyne.io/fyne/v2/internal/driver.walkObjectTree.func1(...)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/util.go:176
fyne.io/fyne/v2/internal/driver.walkObjectTree(0x46723c0, 0xc00014c6c0, 0x4080000040800000, 0x46723c0, 0xc00014cb00, 0x4080000040800000, 0x0, 0x4f0000004f000000, 0xc000629cc8, 0xc000629ca0, ...)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/util.go:190 +0x4f0 fp=0xc000629ac8 sp=0xc000629a08 pc=0x42777f0
fyne.io/fyne/v2/internal/driver.walkObjectTree.func1(...)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/util.go:176
fyne.io/fyne/v2/internal/driver.walkObjectTree(0x46723c0, 0xc00014cb00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4f0000004f000000, 0xc000629cc8, 0xc000629ca0, ...)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/util.go:190 +0x4f0 fp=0xc000629b88 sp=0xc000629ac8 pc=0x42777f0
fyne.io/fyne/v2/internal/driver.WalkVisibleObjectTree(0x46723c0, 0xc00014cb00, 0xc000629cc8, 0xc000629ca0, 0xc0ffffffff)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/util.go:134 +0xa5 fp=0xc000629c00 sp=0xc000629b88 pc=0x42772c5
fyne.io/fyne/v2/internal/driver/glfw.(*glCanvas).walkTree(0xc000354000, 0xc00012edc0, 0xc000629d98, 0xc000629d80)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/canvas.go:537 +0x20b fp=0xc000629d00 sp=0xc000629c00 pc=0x443bf8b
fyne.io/fyne/v2/internal/driver/glfw.(*glCanvas).walkTrees(0xc000354000, 0xc000629d98, 0xc000629d80)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/canvas.go:544 +0x74 fp=0xc000629d50 sp=0xc000629d00 pc=0x443c054
fyne.io/fyne/v2/internal/driver/glfw.(*glCanvas).paint(0xc000354000, 0x43fa000044480000)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/canvas.go:449 +0x14e fp=0xc000629dc8 sp=0xc000629d50 pc=0x443bb4e
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).repaintWindow.func1()
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/loop.go:164 +0xb3 fp=0xc000629e18 sp=0xc000629dc8 pc=0x44529b3
fyne.io/fyne/v2/internal/driver/glfw.(*window).RunWithContext(0xc00017c1c0, 0xc0000a3e40)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/window.go:1181 +0x56 fp=0xc000629e30 sp=0xc000629e18 pc=0x444fff6
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).repaintWindow(0xc0001003c0, 0xc00017c1c0)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/loop.go:155 +0x88 fp=0xc000629e68 sp=0xc000629e30 pc=0x443f1c8
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).startDrawThread.func1(0xc0001003c0, 0xc0001023c0, 0xc000100410)
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/loop.go:211 +0x357 fp=0xc000629fc8 sp=0xc000629e68 pc=0x4452df7
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1374 +0x1 fp=0xc000629fd0 sp=0xc000629fc8 pc=0x4071ac1
created by fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).startDrawThread
/Users/user/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/glfw/loop.go:182 +0xcb

Example code:

For now I assume it will crash with every application given that it crashes way down in the gl code. If this is not the case let me know and I will try to provide minimal reproducable code.

Device (please complete the following information):

  • MacOS Big Sur 11.2.1
  • go version go1.15.7 darwin/amd64
  • fyne.io/fyne/v2 v2.0.0
@tehsphinx tehsphinx added the bug Something isn't working label Feb 14, 2021
@tehsphinx
Copy link
Contributor Author

I just realize this is a dependency, so here the issue for it: go-gl/gl#124

@tehsphinx
Copy link
Contributor Author

Also: go-gl/gl#80

@tehsphinx tehsphinx reopened this Feb 20, 2021
@tehsphinx
Copy link
Contributor Author

From go-gl issue on the subject:

using GODEBUG=cgocheck=0 can disable these checks but seems like kind of a hacky-workaround, especially if you need runtime pointer checks for other packages.

@andydotxyz
Copy link
Member

Looks like an issue triggered by Go 1.14 pingcap/tidb#14972

@dertseha
Copy link

Hello there!
I bring greetings from go-gl/gl, where a PR ( go-gl/gl#135 ) has landed that allows to handle checkptr issues - for the most common GL calls.

For example, instead of calling gl.VertexAttribPointer() the code needs to call the newly available gl.VertexAttribPointerWithOffset() - Note the change in type of the last argument.

There are a few more overloads with WithOffset in their name. There might be more functions that need this treatment - see READMEs of go-gl/glow and go-gl/gl for more details on checkptr and overloads in case more function overloads are needed.

In general, any use of gl.PtrOffset() is discouraged - a future update has it marked as deprecated.

I have not reviewed the fyne code, my proposal is to remove any use of PtrOffset() and ensure direct use of uintptr type - and in case overloads are needed, use those or please report them missing.

andydotxyz added a commit to andydotxyz/fyne that referenced this issue May 13, 2021
@andydotxyz
Copy link
Member

Thanks so much for your hints there @dertseha that worked well and this issue is now resolved :)

@andydotxyz andydotxyz added this to the Aberlour (2.1) milestone May 13, 2021
@andydotxyz
Copy link
Member

This was resolved in 7af0d98, not sure why it was not linked to this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants