Skip to content

Commit

Permalink
flambda-backend: Fix missing restore/save_runtime_state in caml_c_thr…
Browse files Browse the repository at this point in the history
…ead_register for runtime5 (#2739)

(cherry picked from commit c3984ff)
  • Loading branch information
mshinwell authored Jul 1, 2024
1 parent 2572783 commit f0697f9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions otherlibs/systhreads/st_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,11 @@ CAMLexport int caml_c_thread_register(void)
}
/* Associate the thread descriptor with the thread */
st_tls_set(caml_thread_key, (void *) th);

/* Prepare Caml_state for allocation etc., so its various members correspond
to those for the newly-registered thread */
restore_runtime_state(th);

/* Allocate the thread descriptor on the heap */
th->descr = caml_thread_new_descriptor(Val_unit); /* no closure */

Expand All @@ -856,6 +861,9 @@ CAMLexport int caml_c_thread_register(void)
sync_check_error(err, "caml_register_c_thread");
}

/* Save any modifications to Caml_state back to the thread descriptor */
save_runtime_state();

/* Release the master lock */
thread_lock_release(Dom_c_threads);
return 1;
Expand Down

0 comments on commit f0697f9

Please sign in to comment.