summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2019-02-15 23:40:49 +0300
committerIvan Maidanski <ivmai@mail.ru>2019-02-15 23:49:12 +0300
commit4e79c357e853ca8e9ed0df7369f036b0d81326cf (patch)
tree16c344a7acd6123695e42f194cfa23c565b90013 /tests
parent88664f9b753570d0140162cfbdc4e3750b507e67 (diff)
downloadbdwgc-4e79c357e853ca8e9ed0df7369f036b0d81326cf.tar.gz
Avoid unexpected heap growth in gctest caused by GC_disable
(fix of commit 8fc1ebf6d) Issue #264 (bdwgc). This commit eliminates the scenario when one thread disables garbage collections while other threads intensively allocate memory objects. * tests/test.c (run_one_test): Do not call GC_disable and GC_enable. * tests/test.c (run_single_threaded_test): New function (which tests GC_disable and GC_enable). * tests/test.c (main): Call run_single_threaded_test() (before check_heap_stats).
Diffstat (limited to 'tests')
-rw-r--r--tests/test.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/test.c b/tests/test.c
index 764c34a7..8e2e3a6d 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -1470,9 +1470,7 @@ void run_one_test(void)
test_generic_malloc_or_special(GC_malloc_atomic(1));
AO_fetch_and_add1(&atomic_count);
GC_FREE(GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(1));
- GC_disable();
GC_FREE(GC_MALLOC_IGNORE_OFF_PAGE(2));
- GC_enable();
}
}
# ifdef GC_GCJ_SUPPORT
@@ -1597,6 +1595,13 @@ void run_one_test(void)
# endif
}
+/* Execute some tests after termination of other test threads (if any). */
+void run_single_threaded_test(void) {
+ GC_disable();
+ GC_FREE(GC_MALLOC(100));
+ GC_enable();
+}
+
void GC_CALLBACK reachable_objs_counter(void *obj, size_t size,
void *pcounter)
{
@@ -1911,6 +1916,7 @@ void GC_CALLBACK warn_proc(char *msg, GC_word p)
# endif
set_print_procs();
run_one_test();
+ run_single_threaded_test();
check_heap_stats();
# ifndef MSWINCE
fflush(stdout);
@@ -2218,6 +2224,7 @@ DWORD __stdcall thr_window(void * arg GC_ATTR_UNUSED)
if (WaitForSingleObject(win_thr_h, INFINITE) != WAIT_OBJECT_0)
FAIL;
# endif
+ run_single_threaded_test();
check_heap_stats();
# if defined(CPPCHECK) && defined(GC_WIN32_THREADS)
UNTESTED(GC_ExitThread);
@@ -2259,6 +2266,7 @@ int test(void)
!= PCR_ERes_okay || code != 0) {
GC_printf("Thread 2 failed\n");
}
+ run_single_threaded_test();
check_heap_stats();
return(0);
}
@@ -2371,6 +2379,7 @@ int main(void)
}
}
# endif
+ run_single_threaded_test();
check_heap_stats();
(void)fflush(stdout);
(void)pthread_attr_destroy(&attr);