@@ -760,7 +760,7 @@ mono_gc_finalize_notify (void)
760
760
g_message ( "%s: prodding finalizer" , __func__ );
761
761
#endif
762
762
763
- if (mono_gc_is_null () || mono_gc_is_disabled () )
763
+ if (mono_gc_is_null ())
764
764
return ;
765
765
766
766
#ifdef HOST_WASM
@@ -928,6 +928,18 @@ finalizer_thread (gpointer unused)
928
928
/* Register a hazard free queue pump callback */
929
929
mono_hazard_pointer_install_free_queue_size_callback (hazard_free_queue_is_too_big );
930
930
931
+ /* if GC is disabled, we run no finalizer, but we still run mono_w32process_signal_finished
932
+ on the finalizer thread, so that processes can exit. */
933
+ if (mono_gc_is_disabled ())
934
+ {
935
+ while (!finished )
936
+ {
937
+ mono_coop_sem_wait (& finalizer_sem , MONO_SEM_FLAGS_ALERTABLE );
938
+ mono_w32process_signal_finished ();
939
+ }
940
+ return 0 ;
941
+ }
942
+
931
943
while (!finished ) {
932
944
/* Wait to be notified that there's at least one
933
945
* finaliser to run
@@ -995,10 +1007,8 @@ mono_gc_init (void)
995
1007
996
1008
mono_gc_base_init ();
997
1009
998
- if (mono_gc_is_disabled ()) {
1010
+ if (mono_gc_is_disabled ())
999
1011
gc_disabled = TRUE;
1000
- return ;
1001
- }
1002
1012
1003
1013
#ifdef TARGET_WIN32
1004
1014
pending_done_event = CreateEvent (NULL , TRUE, FALSE, NULL );
@@ -1025,9 +1035,9 @@ mono_gc_cleanup (void)
1025
1035
1026
1036
if (mono_gc_is_null ())
1027
1037
return ;
1028
-
1038
+
1039
+ finished = TRUE;
1029
1040
if (!gc_disabled ) {
1030
- finished = TRUE;
1031
1041
if (mono_thread_internal_current () != gc_thread ) {
1032
1042
int ret ;
1033
1043
gint64 start ;
@@ -1086,10 +1096,9 @@ mono_gc_cleanup (void)
1086
1096
}
1087
1097
gc_thread = NULL ;
1088
1098
mono_gc_base_cleanup ();
1089
- }
1090
-
1091
- mono_reference_queue_cleanup ();
1092
1099
1100
+ mono_reference_queue_cleanup ();
1101
+ }
1093
1102
mono_coop_mutex_destroy (& finalizer_mutex );
1094
1103
mono_coop_mutex_destroy (& reference_queue_mutex );
1095
1104
}
0 commit comments