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

al_run_detached_thread: fix segfault on detaching when the thread is already gone #1047

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,12 @@ ALLEGRO_THREAD *al_create_thread_with_stacksize(
void al_run_detached_thread(void *(*proc)(void *arg), void *arg)
{
ALLEGRO_THREAD *outer = create_thread();
_AL_THREAD thread;
outer->thread_state = THREAD_STATE_DETACHED;
outer->arg = arg;
outer->proc = proc;
_al_thread_create(&outer->thread, detached_thread_func_trampoline, outer);
_al_thread_detach(&outer->thread);
_al_thread_create(&thread, detached_thread_func_trampoline, outer);
_al_thread_detach(&thread);
}


Expand Down