Fix ASSERT_CANCEL_DISABLED violation in try_to_collect_inner
authorIvan Maidanski <ivmai@mail.ru>
Wed, 21 Mar 2018 07:26:10 +0000 (10:26 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 21 Mar 2018 07:26:58 +0000 (10:26 +0300)
(fix of commit b04b346)

Issue #182 (bdwgc).

* finalize.c (GC_ON_GROW_LOG_SIZE_MIN): Define to CPP_LOG_HBLKSIZE
value by default.
* finalize.c (GC_grow_table): Surround GC_try_to_collect_inner call
with DISABLE/RESTORE_CANCEL.

finalize.c

index cbe00b8..8c4e380 100644 (file)
@@ -102,7 +102,7 @@ GC_API void GC_CALL GC_push_finalizer_structures(void)
 /* Threshold of log_size to initiate full collection before growing     */
 /* a hash table.                                                        */
 #ifndef GC_ON_GROW_LOG_SIZE_MIN
-# define GC_ON_GROW_LOG_SIZE_MIN 12
+# define GC_ON_GROW_LOG_SIZE_MIN CPP_LOG_HBLKSIZE
 #endif
 
 /* Double the size of a hash table. *log_size_ptr is the log of its     */
@@ -125,7 +125,11 @@ STATIC void GC_grow_table(struct hash_chain_entry ***table,
     /* Avoid growing the table in case of at least 25% of entries can   */
     /* be deleted by enforcing a collection.  Ignored for small tables. */
     if (log_old_size >= GC_ON_GROW_LOG_SIZE_MIN) {
+      IF_CANCEL(int cancel_state;)
+
+      DISABLE_CANCEL(cancel_state);
       (void)GC_try_to_collect_inner(GC_never_stop_func);
+      RESTORE_CANCEL(cancel_state);
       /* GC_finalize might decrease entries value.  */
       if (*entries_ptr < ((word)1 << log_old_size) - (*entries_ptr >> 2))
         return;