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

runtime: garbage collector found invalid heap pointer #14

Closed
Thinkofname opened this issue Mar 25, 2015 · 5 comments
Closed

runtime: garbage collector found invalid heap pointer #14

Thinkofname opened this issue Mar 25, 2015 · 5 comments

Comments

@Thinkofname
Copy link

runtime: garbage collector found invalid heap pointer *(0xc2080b9a10+0x20)=0x6 s=nil
fatal error: invalid heap pointer

runtime stack:
runtime.throw(0x100f463)
    /home/matt/go/src/runtime/panic.go:491 +0xad fp=0x7fd222ffc900 sp=0x7fd222ffc8d0
scanblock(0xc2080b9a10, 0x28, 0x988a40)
    /home/matt/go/src/runtime/mgc0.c:381 +0x551 fp=0x7fd222ffca40 sp=0x7fd222ffc900
scanframe(0x7fd222ffcb48, 0x0, 0x1)
    /home/matt/go/src/runtime/mgc0.c:743 +0x1c2 fp=0x7fd222ffcab0 sp=0x7fd222ffca40
runtime.gentraceback(0x463cd5, 0xc2080b99c8, 0x0, 0xc208000120, 0x0, 0x0, 0x7fffffff, 0x7fd222ffcbf8, 0x0, 0x0, ...)
    /home/matt/go/src/runtime/traceback.go:311 +0x7a8 fp=0x7fd222ffcba0 sp=0x7fd222ffcab0
scanstack(0xc208000120)
    /home/matt/go/src/runtime/mgc0.c:780 +0x21c fp=0x7fd222ffcc10 sp=0x7fd222ffcba0
markroot(0xc208012000, 0x5)
    /home/matt/go/src/runtime/mgc0.c:556 +0xe7 fp=0x7fd222ffcc70 sp=0x7fd222ffcc10
runtime.parfordo(0xc208012000)
    /home/matt/go/src/runtime/parfor.c:91 +0x13b fp=0x7fd222ffccf0 sp=0x7fd222ffcc70
runtime.gchelper()
    /home/matt/go/src/runtime/mgc0.c:1188 +0x4a fp=0x7fd222ffcd18 sp=0x7fd222ffccf0
stopm()
    /home/matt/go/src/runtime/proc.c:1181 +0x158 fp=0x7fd222ffcd38 sp=0x7fd222ffcd18
gcstopm()
    /home/matt/go/src/runtime/proc.c:1351 +0xed fp=0x7fd222ffcd60 sp=0x7fd222ffcd38
schedule()
    /home/matt/go/src/runtime/proc.c:1551 +0x9b fp=0x7fd222ffcd90 sp=0x7fd222ffcd60
runtime.gosched_m(0xc208db4c60)
    /home/matt/go/src/runtime/proc.c:1674 +0xac fp=0x7fd222ffcdb0 sp=0x7fd222ffcd90
runtime.newstack()
    /home/matt/go/src/runtime/stack.c:776 +0x4fa fp=0x7fd222ffce60 sp=0x7fd222ffcdb0
runtime.morestack()
    /home/matt/go/src/runtime/asm_amd64.s:324 +0x7e fp=0x7fd222ffce68 sp=0x7fd222ffce60

goroutine 1 [runnable, locked to thread]:
runtime.cgocall_errno(0x44f0a0, 0xc2080b9a10, 0x2000000000)
    /home/matt/go/src/runtime/cgocall.go:130 +0xf5 fp=0xc2080b99f0 sp=0xc2080b99c8
github.com/go-gl/gl/v2.1/gl._Cfunc_glowVertexAttribPointer(0x7fd232b7cc40, 0x300000001, 0x100001401, 0x9, 0x6)
    github.com/go-gl/gl/v2.1/gl/_obj/_cgo_gotypes.go:20441 +0x45 fp=0xc2080b9a10 sp=0xc2080b99f0
github.com/go-gl/gl/v2.1/gl.VertexAttribPointer(0x300000001, 0x100001401, 0x1a200000009, 0x6)
    /home/matt/gopath/src/github.com/go-gl/gl/v2.1/gl/package.go:26335 +0x69 fp=0xc2080b9a40 sp=0xc2080b9a10

This randomly happens when calling gl.VertexAttribPointer with an offset other than zero, in this case 6. I'm assuming its because Go expects unsafe.Pointer to be pointing to a valid address instead of an offset. Any way to fix/work around?

go version go1.4.2 linux/amd64

@dmitshur
Copy link
Member

Thanks for reporting this issue. This looks like a valid problem that we'll need to fix.

I've never run into it myself because I never tried non-zero pointer offsets.

@Thinkofname
Copy link
Author

My understanding of C is limited but something like this seems to work:

diff --git a/v2.1/gl/package.go b/v2.1/gl/package.go
index 5656428..dd2f17d 100644
--- a/v2.1/gl/package.go
+++ b/v2.1/gl/package.go
@@ -10266,6 +10266,9 @@ package gl
 // static void  glowVertexAttribPointer(GPVERTEXATTRIBPOINTER fnptr, GLuint  index, GLint  size, GLenum  type, GLboolean  normalized, GLsizei  stride, const void * pointer) {
 //   (*fnptr)(index, size, type, normalized, stride, pointer);
 // }
+// static void  glowVertexAttribPointerOffset(GPVERTEXATTRIBPOINTER fnptr, GLuint  index, GLint  size, GLenum  type, GLboolean  normalized, GLsizei  stride, intptr_t pointer) {
+//   (*fnptr)(index, size, type, normalized, stride, (void *) pointer);
+// }
 // static void  glowVertexAttribPointerARB(GPVERTEXATTRIBPOINTERARB fnptr, GLuint  index, GLint  size, GLenum  type, GLboolean  normalized, GLsizei  stride, const void * pointer) {
 //   (*fnptr)(index, size, type, normalized, stride, pointer);
 // }
@@ -26334,6 +26337,10 @@ func VertexAttribParameteriAMD(index uint32, pname uint32, param int32) {
 func VertexAttribPointer(index uint32, size int32, xtype uint32, normalized bool, stride int32, pointer unsafe.Pointer) {
    C.glowVertexAttribPointer(gpVertexAttribPointer, (C.GLuint)(index), (C.GLint)(size), (C.GLenum)(xtype), (C.GLboolean)(boolToInt(normalized)), (C.GLsizei)(stride), pointer)
 }
+func VertexAttribPointerOffset(index uint32, size int32, xtype uint32, normalized bool, stride int32, pointer uintptr) {
+   C.glowVertexAttribPointerOffset(gpVertexAttribPointer, (C.GLuint)(index), (C.GLint)(size), (C.GLenum)(xtype), (C.GLboolean)(boolToInt(normalized)), (C.GLsizei)(stride), (C.intptr_t)(pointer))
+}
+
 func VertexAttribPointerARB(index uint32, size int32, xtype uint32, normalized bool, stride int32, pointer unsafe.Pointer) {
    C.glowVertexAttribPointerARB(gpVertexAttribPointerARB, (C.GLuint)(index), (C.GLint)(size), (C.GLenum)(xtype), (C.GLboolean)(boolToInt(normalized)), (C.GLsizei)(stride), pointer)
 }

@pwaller
Copy link
Member

pwaller commented Jun 5, 2016

Ping.

I guess these issues have since been dealt with, is that true @shurcooL?

@dmitshur
Copy link
Member

dmitshur commented Jun 5, 2016

As far as I know, there was no action take to deal with this.

I think I missed @Thinkofname's reply and forgot about this issue.

To resolve it, we'll need a reproduce case to confirm it's still an issue, and then try the fix @Thinkofname suggested.

@errcw
Copy link
Member

errcw commented Feb 20, 2018

Ultimately a duplicate of #80, and the relevant discussion is there, so I'm going to close this issue.

@errcw errcw closed this as completed Feb 20, 2018
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

4 participants