Skip to content

Commit f0697f9

Browse files
authored
flambda-backend: Fix missing restore/save_runtime_state in caml_c_thread_register for runtime5 (#2739)
(cherry picked from commit c3984ff)
1 parent 2572783 commit f0697f9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

otherlibs/systhreads/st_stubs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,11 @@ CAMLexport int caml_c_thread_register(void)
848848
}
849849
/* Associate the thread descriptor with the thread */
850850
st_tls_set(caml_thread_key, (void *) th);
851+
852+
/* Prepare Caml_state for allocation etc., so its various members correspond
853+
to those for the newly-registered thread */
854+
restore_runtime_state(th);
855+
851856
/* Allocate the thread descriptor on the heap */
852857
th->descr = caml_thread_new_descriptor(Val_unit); /* no closure */
853858

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

864+
/* Save any modifications to Caml_state back to the thread descriptor */
865+
save_runtime_state();
866+
859867
/* Release the master lock */
860868
thread_lock_release(Dom_c_threads);
861869
return 1;

0 commit comments

Comments
 (0)