cancellable test leaks many GCancellableSource objects
To reproduce:
- recent GLib (I used c07f8a70 as a base, with !1905 (merged) applied)
- a recent GNU/Linux system (I used Debian's
unstable
rolling release) - build GLib with gcc AddressSanitizer (
-Db_sanitize=address
in Meson)- I used Debian's gcc 10.2.1-6
- I used UndefinedBehaviourSanitizer too (
-Db_sanitize=address,undefined
) but that probably doesn't matter - clang AddressSanitizer would probably also reproduce this
- if !1905 (merged) has been applied, partially or fully revert commit "tests: Mark tests with AddressSanitizer-detected leaks" to re-expose this leak
- run unit tests, specifically
glib:gio / cancellable
(akagio/tests/cancellable.c
)
Expected result: no memory is leaked and unreachable on process exit.
Actual result:
=================================================================
==3042833==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 62160 byte(s) in 518 object(s) allocated from:
#0 0x7f2296d15037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
#1 0x7f22965ea87a in g_malloc0 ../../../../../../home/smcv/src/glib/glib/gmem.c:136
#2 0x7f22965b09df in g_source_new ../../../../../../home/smcv/src/glib/glib/gmain.c:958
#3 0x7f229509a8b4 in g_cancellable_source_new ../../../../../../home/smcv/src/glib/gio/gcancellable.c:800
#4 0x55fde1322076 in test_cancellable_source_threaded_dispose ../../../../../../home/smcv/src/glib/gio/tests/cancellable.c:293
#5 0x7f229667cdf2 in test_case_run ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2764
#6 0x7f229667d9f2 in g_test_run_suite_internal ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2852
#7 0x7f229667dc7c in g_test_run_suite_internal ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2869
#8 0x7f229667e3a2 in g_test_run_suite ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2946
#9 0x7f229667aa72 in g_test_run ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2157
#10 0x55fde132242a in main ../../../../../../home/smcv/src/glib/gio/tests/cancellable.c:340
#11 0x7f2293ef7d09 in __libc_start_main ../csu/libc-start.c:308
Indirect leak of 16576 byte(s) in 518 object(s) allocated from:
#0 0x7f2296d14e8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x7f22965ea811 in g_malloc ../../../../../../home/smcv/src/glib/glib/gmem.c:106
#2 0x7f22965eab43 in g_malloc_n ../../../../../../home/smcv/src/glib/glib/gmem.c:344
#3 0x7f22965b838a in g_source_set_callback ../../../../../../home/smcv/src/glib/glib/gmain.c:1778
#4 0x55fde13220b8 in test_cancellable_source_threaded_dispose ../../../../../../home/smcv/src/glib/gio/tests/cancellable.c:294
#5 0x7f229667cdf2 in test_case_run ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2764
#6 0x7f229667d9f2 in g_test_run_suite_internal ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2852
#7 0x7f229667dc7c in g_test_run_suite_internal ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2869
#8 0x7f229667e3a2 in g_test_run_suite ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2946
#9 0x7f229667aa72 in g_test_run ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2157
#10 0x55fde132242a in main ../../../../../../home/smcv/src/glib/gio/tests/cancellable.c:340
#11 0x7f2293ef7d09 in __libc_start_main ../csu/libc-start.c:308
Indirect leak of 6734 byte(s) in 518 object(s) allocated from:
#0 0x7f2296d14e8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x7f22965ea811 in g_malloc ../../../../../../home/smcv/src/glib/glib/gmem.c:106
#2 0x7f22965eab43 in g_malloc_n ../../../../../../home/smcv/src/glib/glib/gmem.c:344
#3 0x7f2296660e3b in g_strdup ../../../../../../home/smcv/src/glib/glib/gstrfuncs.c:364
#4 0x7f22965babf8 in g_source_set_name ../../../../../../home/smcv/src/glib/glib/gmain.c:2102
#5 0x7f229509a8cb in g_cancellable_source_new ../../../../../../home/smcv/src/glib/gio/gcancellable.c:801
#6 0x55fde1322076 in test_cancellable_source_threaded_dispose ../../../../../../home/smcv/src/glib/gio/tests/cancellable.c:293
#7 0x7f229667cdf2 in test_case_run ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2764
#8 0x7f229667d9f2 in g_test_run_suite_internal ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2852
#9 0x7f229667dc7c in g_test_run_suite_internal ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2869
#10 0x7f229667e3a2 in g_test_run_suite ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2946
#11 0x7f229667aa72 in g_test_run ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2157
#12 0x55fde132242a in main ../../../../../../home/smcv/src/glib/gio/tests/cancellable.c:340
#13 0x7f2293ef7d09 in __libc_start_main ../csu/libc-start.c:308
SUMMARY: AddressSanitizer: 85470 byte(s) leaked in 1554 allocation(s).
This is probably a bug in GCancellable, or it might be a bug in the test, or a false-positive?
For now, I've marked this test g_test_incomplete()
when running under AddressSanitizer, so that we can run the rest of the test-suite under AddressSanitizer and at least make sure we don't regress.