]> granicus.if.org Git - gc/commitdiff
Fix assertion violation about the number of freed objects in test_cpp
authorIvan Maidanski <ivmai@mail.ru>
Mon, 25 Feb 2019 21:51:45 +0000 (00:51 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 25 Feb 2019 21:51:45 +0000 (00:51 +0300)
(fix of commit 6e0590ef1)

Issue Unity-Technologies#37 (bdwgc).

* tests/test_cpp.cc (C::Test): Call GC_gcollect() if incremental mode
and nFreed is too low.

tests/test_cpp.cc

index fe7244bfc0403fcc475e8086618ae9c8f52cb94d..4b24b25efaab6e7fd2c095324d7fed227a77df4b 100644 (file)
@@ -158,6 +158,11 @@ class C: public GC_NS_QUALIFY(gc_cleanup), public A { public:
         left = right = 0;
         level = -123456;}
     static void Test() {
+        if (GC_is_incremental_mode() && nFreed < (nAllocated / 5) * 4) {
+          // An explicit GC might be needed to reach the expected number
+          // of the finalized objects.
+          GC_gcollect();
+        }
         my_assert(nFreed <= nAllocated);
         my_assert(nFreed >= (nAllocated / 5) * 4 || GC_get_find_leak());
     }