From 54b0393b7edcdac17b3bd05e1afc98bd4c1ac8fb Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 10 Dec 2016 10:37:04 +0300 Subject: [PATCH] Fix GC_mark_stack_top assertion violation properly in mark_local (fix commit a563b883) * mark.c (GC_mark_local): Remove assertion checking that global_first_nonempty is not greater than GC_mark_stack_top+1 (because global_first_nonempty could be bigger slightly more at some moments due to concurrency between the markers); replace n_on_stack==0 with my_top= (word)GC_mark_stack && - (word)global_first_nonempty <= - (word)AO_load_acquire((volatile AO_t *)&GC_mark_stack_top) - + sizeof(mse)); + GC_ASSERT((word)global_first_nonempty >= (word)GC_mark_stack); if ((word)my_first_nonempty < (word)global_first_nonempty) { my_first_nonempty = global_first_nonempty; } else if ((word)global_first_nonempty < (word)my_first_nonempty) { @@ -1087,8 +1084,7 @@ STATIC void GC_mark_local(mse *local_mark_stack, int id) /* Perhaps we should also update GC_first_nonempty, if it */ /* is less. But that would require using atomic updates. */ my_top = (mse *)AO_load_acquire((volatile AO_t *)(&GC_mark_stack_top)); - n_on_stack = my_top - my_first_nonempty + 1; - if (0 == n_on_stack) { + if ((word)my_top < (word)my_first_nonempty) { GC_acquire_mark_lock(); my_top = GC_mark_stack_top; /* Asynchronous modification impossible here, */ @@ -1135,6 +1131,8 @@ STATIC void GC_mark_local(mse *local_mark_stack, int id) } else { GC_release_mark_lock(); } + } else { + n_on_stack = my_top - my_first_nonempty + 1; } n_to_get = ENTRIES_TO_GET; if (n_on_stack < 2 * ENTRIES_TO_GET) n_to_get = 1; -- 2.40.0