summaryrefslogtreecommitdiff
path: root/otherlibs/systhreads/st_stubs.c
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/systhreads/st_stubs.c')
-rw-r--r--otherlibs/systhreads/st_stubs.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/otherlibs/systhreads/st_stubs.c b/otherlibs/systhreads/st_stubs.c
index ba10205eb1..9b2493a16e 100644
--- a/otherlibs/systhreads/st_stubs.c
+++ b/otherlibs/systhreads/st_stubs.c
@@ -344,7 +344,10 @@ static value caml_thread_new_descriptor(value clos)
static void caml_thread_remove_info(caml_thread_t th)
{
- if (th->next == th) all_threads = NULL; /* last OCaml thread exiting */
+ if (th->next == th)
+ all_threads = NULL; /* last OCaml thread exiting */
+ else if (all_threads == th)
+ all_threads = th->next; /* PR#5295 */
th->next->prev = th->prev;
th->prev->next = th->next;
#ifndef NATIVE_CODE