testfilemonitor test leaks ip_watched_file_t struct
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+slow+flaky / testfilemonitor
(akagio/tests/testfilemonitor.c
)
Expected result: no memory is leaked and unreachable on process exit.
Actual result:
=================================================================
==3146511==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 32 byte(s) in 1 object(s) allocated from:
#0 0x7f42e9fc2037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
#1 0x7f42e989787a in g_malloc0 ../../../../../../home/smcv/src/glib/glib/gmem.c:136
#2 0x7f42e9897bda in g_malloc0_n ../../../../../../home/smcv/src/glib/glib/gmem.c:368
#3 0x7f42e8761fc4 in ip_watched_file_new ../../../../../../home/smcv/src/glib/gio/inotify/inotify-path.c:197
#4 0x7f42e87630e0 in _ip_start_watching ../../../../../../home/smcv/src/glib/gio/inotify/inotify-path.c:292
#5 0x7f42e87665f5 in _ih_sub_add ../../../../../../home/smcv/src/glib/gio/inotify/inotify-helper.c:107
#6 0x7f42e876808e in g_inotify_file_monitor_start ../../../../../../home/smcv/src/glib/gio/inotify/ginotifyfilemonitor.c:65
#7 0x7f42e872b33f in g_local_file_monitor_start ../../../../../../home/smcv/src/glib/gio/glocalfilemonitor.c:803
#8 0x7f42e872b8fd in g_local_file_monitor_new_for_path ../../../../../../home/smcv/src/glib/gio/glocalfilemonitor.c:887
#9 0x7f42e87108a9 in g_local_file_monitor_file ../../../../../../home/smcv/src/glib/gio/glocalfile.c:2636
#10 0x7f42e83929a0 in g_file_monitor_file ../../../../../../home/smcv/src/glib/gio/gfile.c:5496
#11 0x5597ba057cc0 in test_file_hard_links ../../../../../../home/smcv/src/glib/gio/tests/testfilemonitor.c:978
#12 0x7f42e9929df2 in test_case_run ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2764
#13 0x7f42e992a9f2 in g_test_run_suite_internal ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2852
#14 0x7f42e992ac7c in g_test_run_suite_internal ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2869
#15 0x7f42e992ac7c in g_test_run_suite_internal ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2869
#16 0x7f42e992b3a2 in g_test_run_suite ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2946
#17 0x7f42e9927a72 in g_test_run ../../../../../../home/smcv/src/glib/glib/gtestutils.c:2157
#18 0x5597ba058394 in main ../../../../../../home/smcv/src/glib/gio/tests/testfilemonitor.c:1023
#19 0x7f42e71a4d09 in __libc_start_main ../csu/libc-start.c:308
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.