Repository navigation
Closed
Labels
meson testsIssues and PRs relating to the Meson project functional and unit tests.Issues and PRs relating to the Meson project functional and unit tests.
Description
Describe the bug
The test_generate_gir_with_address_sanitizer test fails on my machine.
Testsuite output
▸ ./run_unittests.py -v -ktest_generate_gir_with_address_sanitizer
[…]
[77/126] Generating gir/dep1/dep2/MesonDep2-1.0.gir with a custom command (wrapped by meson to set env)
FAILED: gir/dep1/dep2/MesonDep2-1.0.gir
env PKG_CONFIG_PATH=[…]/meson/tmpdbxb23ra/meson-uninstalled 'CC=sccache cc' /usr/bin/g-ir-scanner --quiet --no-libtool --namespace=MesonDep2 --nsversion=1.0 --warn-all --output gir/dep1/dep2/MesonDep2-1.0.gir '-I[…]/meson/test cases/frameworks/7 gnome/gir/dep1/dep2' -I[…]/meson/tmpdbxb23ra/gir/dep1/dep2 --filelist=[…]/meson/tmpdbxb23ra/gir/dep1/dep2/libdep2lib.so.p/MesonDep2_1.0_gir_filelist --include=GObject-2.0 --symbol-prefix=meson --identifier-prefix=Meson --cflags-begin -DMESON_TEST_1 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/gobject-introspection-1.0 --cflags-end --add-include-path=/usr/share/gir-1.0 -lasan -L[…]/meson/tmpdbxb23ra/gir/dep1/dep2 --library dep2lib --extra-library=gobject-2.0 --extra-library=glib-2.0 --extra-library=girepository-1.0 --sources-top-dirs '[…]/meson/test cases/frameworks/7 gnome/' --sources-top-dirs […]/meson/tmpdbxb23ra/
/usr/lib/gobject-introspection/giscanner/scannermain.py:343: EncodingWarning: 'encoding' argument not specified
with open(options.filelist, "r", encoding=None) as filelist_file:
=================================================================
==76350==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 280 byte(s) in 2 object(s) allocated from:
#0 0x7f4fdcabf411 in __interceptor_calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f4fdc8b3a31 in g_malloc0 (/usr/lib/libglib-2.0.so.0+0x5fa31)
Indirect leak of 4164 byte(s) in 2 object(s) allocated from:
#0 0x7f4fdcabfa89 in __interceptor_malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x7f4fdc8b2e19 in g_malloc (/usr/lib/libglib-2.0.so.0+0x5ee19)
Indirect leak of 96 byte(s) in 1 object(s) allocated from:
#0 0x7f4fdcabf411 in __interceptor_calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7f4fdc8b3a31 in g_malloc0 (/usr/lib/libglib-2.0.so.0+0x5fa31)
Indirect leak of 28 byte(s) in 1 object(s) allocated from:
#0 0x7f4fdcabfa89 in __interceptor_malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x7f4fdc512330 (/usr/lib/libc.so.6+0x7a330)
#2 0xcbedc2ef920422ff (<unknown module>)
SUMMARY: AddressSanitizer: 4568 byte(s) leaked in 6 allocation(s).
Command '['[…]/meson/tmpdbxb23ra/tmp-introspectrfshifd7/MesonDep2-1.0', '--introspect-dump=[…]/meson/tmpdbxb23ra/tmp-introspectrfshifd7/functions.txt,[…]/meson/tmpdbxb23ra/tmp-introspectrfshifd7/dump.xml']' returned non-zero exit status 1.
[78/126] Compiling C object mkenums/enumprog4.p/meson-generated_.._enums4.c.o
[…]
System parameters
- operating system: Arch Linux 64 bit
- what Python version are you using e.g. 3.8.0
meson --version: 1.1.0-57-g7388737c7ninja --version: 1.11.1
Workaround
Run the testsuite with: env 'LSAN_OPTIONS=exitcode=0' ./run_unittests.py -v -ktest_generate_gir_with_address_sanitizer.
Tentative patch
mesonbuild/modules/gnome.py | 2 ++
1 file changed, 2 insertions(+)
diff --git i/mesonbuild/modules/gnome.py w/mesonbuild/modules/gnome.py
index 7d471e4ce..e8acb03a2 100644
--- i/mesonbuild/modules/gnome.py
+++ w/mesonbuild/modules/gnome.py
@@ -982,6 +982,8 @@ class GnomeModule(ExtensionModule):
# g-ir-scanner uses Python's distutils to find the compiler, which uses 'CC'
cc_exelist = state.environment.coredata.compilers.host['c'].get_exelist()
run_env.set('CC', [quote_arg(x) for x in cc_exelist], ' ')
+ # Don't fail if the build is using `-Db_sanitize=address`.
+ run_env.set('LSAN_OPTIONS', 'exitcode=0', '')
run_env.merge(kwargs['env'])
return GirTarget(Metadata
Metadata
Assignees
Labels
meson testsIssues and PRs relating to the Meson project functional and unit tests.Issues and PRs relating to the Meson project functional and unit tests.
Activity
eli-schwartz commentedon May 10, 2023
This also prevents CI from rebuilding our images. Seems likely to be an underlying glib problem...
@xclaesse any idea?
ciimage: fix pathological brokenness in Debian packaging of python
eli-schwartz commentedon May 28, 2023
@ebassi I bisected glib for this, and GNOME/glib@3b7af4d is the commit that introduced this asan failure.
benoit-pierre commentedon May 29, 2023
So who knows how old the leak is...
benoit-pierre commentedon May 29, 2023
I mean, did you bisect with
G_SLICE=always-malloc?eli-schwartz commentedon May 29, 2023
Okay yes that demonstrates the issue as far back as 2.70 at least (I didn't spot check further, just verified that that bisected commit only uncovered a pre-existing issue).
ebassi commentedon May 29, 2023
It would probably be easier if ASan printed out a backtrace, to see which object is getting allocated without getting freed.
That commit appears because the object allocation was switched from the slice allocator to the system one, so anything that was masked by GSlice being opaque to ASan is now visible.
xclaesse commentedon Jul 18, 2023
I'm tried to reproduce this issue, but
env 'LSAN_OPTIONS=exitcode=0' ./run_unittests.py -v -ktest_generate_gir_with_address_sanitizerworks just fine on my Ubuntu. I assume I have to build glib with-Db_sanitize=leak, but then I run meson unit test inside glib's devenv and that test gets skipped... @eli-schwartz how are you reproducing?xclaesse commentedon Jul 18, 2023
Found that it gets skipped because:
I don't know what that means...
xclaesse commentedon Jul 18, 2023
Oh actually I can reproduce with Ubuntu glib version, it's just the
env 'LSAN_OPTIONS=exitcode=0'in the bug report that makes no sense, that hide the issue...xclaesse commentedon Jul 18, 2023
I got better backtraces with
ASAN_OPTIONS=fast_unwind_on_malloc=0:xclaesse commentedon Jul 18, 2023
Here is a fix of the leak in gobject-introspection: https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/411.
Until that fix reaches our CI distro, we probably need to use the workaround proposed: LSAN_OPTIONS=exitcode=0.
ci: Fix failing test_generate_gir_with_address_sanitizer test
ci: Fix failing test_generate_gir_with_address_sanitizer test
gdump: Fix leaked io streams
ci: Skip test_generate_gir_with_address_sanitizer
ci: Skip test_generate_gir_with_address_sanitizer
ci: Skip test_generate_gir_with_address_sanitizer
ci: Skip test_generate_gir_with_address_sanitizer
ci: Skip test_generate_gir_with_address_sanitizer
3v1n0 commentedon Aug 10, 2023
Thanks for the upstream fix (I was about to be annoyed enough to do it too :-D), however another trick to get the tests working is compiling with
ASAN_OPTIONS=start_deactivated=true,detect_leaks=0and then usingmeson testwithout that.ci: Skip test_generate_gir_with_address_sanitizer
gdump: Fix leaked io streams
ci: Skip test_generate_gir_with_address_sanitizer