Browse Source

fixed race condition in gc mark threads

Nicolas Cannasse 2 years ago
parent
commit
6e754cce62
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/gc.c

+ 2 - 2
src/gc.c

@@ -895,8 +895,8 @@ static void mark_thread_main( void *param ) {
 	while( true ) {
 		hl_semaphore_acquire(inf->ready);
 		inf->mark_count += gc_flush_mark(&inf->stack);
-		hl_semaphore_release(mark_threads_done);
-		atomic_bit_unset(&mark_threads_active, 1 << index);
+		while( !atomic_bit_unset(&mark_threads_active, 1 << index) ) {};
+		if( mark_threads_active == 0 ) hl_semaphore_release(mark_threads_done);
 	}
 }