meson: fix a crash when building
When starting a build stage on_build_stage_query()
would crash when
the IdeSubprocessLauncher
had a command line of more than 2 items and
none of those were ninja or ninja-build.
Found the crash when using a jhbuild pipeline, since its argv is
jhbuild run ninja
, the first loop got stuck on comparing jhbuild
against ninja, ninja-build, and then infinity.
The above because g_strv_contains()
expects NULL terminated arrays,
otherwise it will start accessing random memory and likely crash.
Reference crash:
Thread 1 (Thread 0x7f2ea15c0640 (LWP 131524)):
#0 0x00007f2ea9ebca5e in __waitpid (pid=132391, stat_loc=0x0, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
#1 0x0000563ce2e26486 in bug_buddy_sigsegv_handler (signum=11) at ../../../../gnome/gnome-builder/src/bug-buddy.c:53
#2 <signal handler called>
#3 __strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:102
#4 0x00007f2eae536a69 in g_str_equal (v1=v1@entry=0x563ce65c5ca0, v2=<optimized out>) at ../../../../gnome/glib/glib/ghash.c:2303
#5 0x00007f2eae5689f5 in g_strv_contains (strv=0x563ce361b7b0 <sizes>, str=0x563ce65c5ca0 "jhbuild") at ../../../../gnome/glib/glib/gstrfuncs.c:3190
#6 0x0000563ce3155931 in on_build_stage_query (stage=0x563ce5390cb0, pipeline=0x563ce565a060, targets=0x7f2e28c7e260, cancellable=0x563ce59bc2a0) at ../../../../gnome/gnome-builder/src/plugins/meson/gbp-meson-pipeline-addin.c:62
Edited by Diego Escalante Urrelo