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
Segmentation Violation with Draw Process #355
Comments
Hi @SolarLune, this issue is difficult to track... Testing it with raylib C version, it seems to work ok. I'd need a clearer C sample to track the issue... Maybe is related to Go lang? @gen2brain any idea? |
This isn't tied to Raylib or the Go binding, but to Go itself. Go implements its own work-stealing scheduler (nicely explained here), which means that Go may move tasks to different OS threads. Since your loop is allocating a whole lot of Player objects, Go's garbage collection eventually kicks in. (Replacing the loop with a call to The solution is to make one of the threads explicitly responsible for talking to raylib. The easiest way of doing that would be to call func main() {
runtime.LockOSThread()
raylib.InitWindow(320, 240, "Test Game")
// ... This approach isn't ideal, so for a larger project, I would recommend implementing a way to pass work to the main thread or use a package like mainthread to do it for you. With that being said, I think it might be good to have a note about calling raylib from the main thread somewhere in the library or binding docs. I don't think the library itself needs to handle multithreading in any way - however, it might not immediately be obvious why you can't, say, create threads to draw sprites in parallel (even moreso in Go, where goroutines are core to the language) |
Just closing this issue here. I'll follow the linked thread... |
Hey, there. I'm using raylib-go, and I'm getting a fatal error from raylib's draw process after a few frames:
And here's the error:
This is a bit of an unusual example that wouldn't come up normally, but I also get a segmentation violation (seemingly randomly) when attempting to load a texture from a filepath. I assume the reason is linked.
The text was updated successfully, but these errors were encountered: