-
Notifications
You must be signed in to change notification settings - Fork 260
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
cute_sync SDL implementation has intermittent segfaults #313
Comments
This is 2 years old, you've probably already figured this out, but I had the same issue and I think I have figured it out. I believe the issue is that cute_threadpool_kick_and_wait() exits when all tasks are "started" and not when there finished. So when it exits the last couple of tasks are still being executed. My hack solution is to have a boolean attached to each task that I set to true after the work is done and just check for that after the _kick_and_wait() but it would be nice if this was the way that the function worked in the first place. |
Hey awesome! I haven’t used this code for some time — if you have a PR that would be really cool :) |
I have an issue with
cute_threadpool_kick_and_wait
resulting in intermittent segfaults when using the SDL implementation.I allocate memory then I pass this memory to the task function to do some async computation with
cute_threadpool_add_task
. Then, I callcute_threadpool_kick_and_wait
expecting the function to wait and join on all the added tasks to free all my memory. But when I do free all my memory, I get a segfault in the task function for accessing freed memory, meaning the task function is still running after callingcute_threadpool_kick_and_wait
.Am I misunderstanding what this function does? I'm expecting it to block the thread I am calling it from and wait until all the tasks are completed.
This is the code to reproduce:
If I run this code 10 times it will segfault about half of the time.
It doesn't segfault if I use the POSIX implementation making me think it's something specific to the SDL implementation.
The text was updated successfully, but these errors were encountered: