-
Notifications
You must be signed in to change notification settings - Fork 182
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
panic in gl "cgo argument has Go pointer to Go pointer" #200
Comments
What version of Go are you using? Show output of Do you have the latest commit This is something we fixed a while ago (see go-gl/gl#31), so I wanna check if you're using old stuff or latest stuff. Also, why did you post this issue in glfw repo, when the panic seems to be in gl repo? |
currently, 1.6.2, but originally, 1.6.1, i think, and also have tried 1.8.(1/2/3)
i did a fresh update to my installed go packages, glfw and gl, before reporting, using 'go get -u' if it helps - i find this in gl/package.go; (i also updated glfw lib from 3.12 to 3.21, but this was for other reasons not related to this.)
sorry, yes, since i cant really use them separately, i just lazily conflated them mentally. i can re-report if that helps? |
i also just double checked, gl's code archive was rebuilt automatically after the update. |
Which of these https://godoc.org/github.com/go-gl/glfw versions are you using? |
3.2 (and tested with 3.1) both same error. this is now with me having deleted all local go-gl and reinstalled. |
Ok, so this might be a valid bug then. Can you please provide full information (what OS you're using, etc.) and a small snippet to help us reproduce this? If we can reproduce it with latest version, we should be able to fix it. Thanks for the report. |
Actually, the panic is in |
i guess this would be where an issue might be, but i'm not seeing it:
|
That code does contain a problem. You're passing a pointer to
Cgo memory passing rules disallow passing a Go pointer to Go pointer as of Go 1.6. You should allocate C memory, copy the Go string in there, and pass a pointer to that. We've created https://godoc.org/github.com/go-gl/gl/v2.1/gl#Strs So your thisShader := gl.CreateShader(stype)
csources, free := gl.Strs(source)
gl.ShaderSource(thisShader, 1, csources, nil)
free()
gl.CompileShader(thisShader) I got that code from the Hopefully that fixes your problem. I wonder if there's some change we can make to the documentation to make this solution more discoverable. |
thanks, just wondering, why not put that inside the CreateShader function? |
Sorry, I can't answer your question because I'm boarding a plane, see https://twitter.com/shurcool/status/871528913108971520. Hopefully someone else can answer it. |
The short answer is that these bindings attempt to mirror the OpenGL function definitions as closely as possible. A higher level library could certainly wrap some of these sharp edges, but that's not the intention of this particular library. |
closing due to my misunderstanding. |
further to this, using Strs() func broke all my shaders.... |
about a year ago i started getting this sort of thing;
found out it was due to a strictness increase, and have been using "GODEBUG=cgocheck=0" to avoid.
didn't report because i thought it was a general issue that would have to be sorted in the fullness of time.
reporting now because it bit me, i forgot the hack, and i then noticed #156.
The text was updated successfully, but these errors were encountered: