File tree Expand file tree Collapse file tree
ocaml/otherlibs/systhreads Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments