Merge branch 'wip/3v1n0/ci-sanitizer-tests' into 'main'

Draft: CI: Add Memory and Thread Sanitizer jobs

Closes #3356

See merge request GNOME/glib!4062
This commit is contained in:
Marco Trevisan 2024-07-15 21:24:53 +00:00
commit 0ad8a7e09e
18 changed files with 656 additions and 119 deletions

View File

@ -11,7 +11,7 @@ cache:
- _ccache/
variables:
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v27"
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v28"
COVERITY_IMAGE: "registry.gitlab.gnome.org/gnome/glib/coverity:v7"
DEBIAN_IMAGE: "registry.gitlab.gnome.org/gnome/glib/debian-stable:v19"
ALPINE_IMAGE: "registry.gitlab.gnome.org/gnome/glib/alpine:v3"
@ -194,9 +194,9 @@ fedora-x86_64:
_build
- meson compile -C _build
- mkdir -p _coverage
- lcov --config-file .lcovrc --directory _build --capture --initial --output-file "_coverage/${CI_JOB_NAME}-baseline.lcov"
- lcov --config-file .lcovrc --directory _build --capture --initial --ignore-errors source --output-file "_coverage/${CI_JOB_NAME}-baseline.lcov"
- .gitlab-ci/run-tests.sh
- lcov --config-file .lcovrc --directory _build --capture --output-file "_coverage/${CI_JOB_NAME}.lcov"
- lcov --config-file .lcovrc --directory _build --capture --ignore-errors source --output-file "_coverage/${CI_JOB_NAME}.lcov"
# Copy the built documentation to an artifact directory. The build for docs.gtk.org
# can then pull it from there — see https://gitlab.gnome.org/GNOME/gtk/-/blob/docs-gtk-org/README.md
- mkdir -p _reference/
@ -443,6 +443,80 @@ valgrind:
- "_build/glib/glibconfig.h"
- "_build/meson-logs"
address-sanitizer:
extends:
- .build-linux
- .only-schedules-or-manual
- .with-git
image: $FEDORA_IMAGE
stage: analysis
tags: [asan]
needs: []
variables:
MESON_TEST_TIMEOUT_MULTIPLIER: 5
before_script:
- !reference [".build-linux", "before_script"]
- !reference [".with-git", "before_script"]
script:
- meson setup ${MESON_COMMON_OPTIONS}
--werror
-Dsystemtap=enabled
-Ddtrace=enabled
-Dinstalled_tests=true
-Dintrospection=enabled
-Db_sanitize=address,undefined
_build
# Do not run ninja, let meson handle the build dependencies!
# This tests that all tests have the right build dependencies specified.
- bash -x ./.gitlab-ci/run-tests.sh
artifacts:
reports:
junit: "_build/meson-logs/testlog.junit.xml"
name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
when: always
expire_in: 1 week
paths:
- "_build/config.h"
- "_build/glib/glibconfig.h"
- "_build/meson-logs"
thread-sanitizer:
extends:
- .build-linux
- .only-schedules-or-manual
- .with-git
image: $FEDORA_IMAGE
stage: analysis
tags: [asan]
needs: []
variables:
MESON_TEST_TIMEOUT_MULTIPLIER: 10
before_script:
- !reference [".build-linux", "before_script"]
- !reference [".with-git", "before_script"]
script:
- meson setup ${MESON_COMMON_OPTIONS}
--werror
-Dsystemtap=enabled
-Ddtrace=enabled
-Dinstalled_tests=true
-Dintrospection=enabled
-Db_sanitize=thread
_build
# Do not run ninja, let meson handle the build dependencies!
# This tests that all tests have the right build dependencies specified.
- bash -x ./.gitlab-ci/run-tests.sh --no-suite=no-tsan
artifacts:
reports:
junit: "_build/meson-logs/testlog.junit.xml"
name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
when: always
expire_in: 1 week
paths:
- "_build/config.h"
- "_build/glib/glibconfig.h"
- "_build/meson-logs"
.cross-build-linux:
extends: .build-linux
stage: build

View File

@ -40,10 +40,13 @@ RUN dnf -y update \
gtk-doc \
itstool \
lcov \
libasan \
libattr-devel \
libffi-devel \
libmount-devel \
libselinux-devel \
libtsan \
libubsan \
libxslt \
ncurses-compat-libs \
ninja-build \

View File

@ -30,6 +30,7 @@
#include "config.h"
#include "gsocket.h"
#include "glib-private.h"
#ifdef G_OS_UNIX
#include "glib-unix.h"
@ -4369,6 +4370,10 @@ socket_source_new (GSocket *socket,
GSource *cancellable_source;
cancellable_source = g_cancellable_source_new (cancellable);
/* FIXME: The cancellable source may not be ever released, see:
* - https://gitlab.gnome.org/GNOME/glib/-/issues/2309
*/
g_ignore_leak (cancellable_source);
g_source_add_child_source (source, cancellable_source);
g_source_set_dummy_callback (cancellable_source);
g_source_unref (cancellable_source);

View File

@ -539,7 +539,7 @@ test_connection_signal_handler (GDBusConnection *connection,
/* We defer quitting to a G_PRIORITY_DEFAULT_IDLE function so other queued signal
* callbacks have a chance to run first. They get dispatched with a higher priority
* of G_PIORITY_DEFAULT, so as long as the queue is non-empty g_main_loop_quit won't
* of G_PRIORITY_DEFAULT, so as long as the queue is non-empty g_main_loop_quit won't
* run
*/
g_idle_add_once ((GSourceOnceFunc) g_main_loop_quit, loop);

View File

@ -1928,6 +1928,17 @@ test_threaded_unregistration_iteration (gboolean subtree)
g_clear_object (&call_result);
g_clear_object (&data.connection);
/* We defer quitting to a G_PRIORITY_DEFAULT_IDLE function so other queued
* signal callbacks have a chance to run first.
* In particular we want to ensure that all calls to on_object_unregistered()
* are delivered here before we end this function, so that there won't be any
* invalid stack access.
* They get dispatched with a higher priority (G_PRIORITY_DEFAULT), so as
* long as the queue is non-empty g_main_loop_quit won't run
*/
g_idle_add_once ((GSourceOnceFunc) g_main_loop_quit, loop);
g_main_loop_run (loop);
return unregistration_was_first;
}

View File

@ -52,14 +52,19 @@ gio_tests = {
'appmonitor' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
'can_fail' : host_system in ['darwin', 'gnu'],
'can_fail' : host_system in ['darwin', 'gnu'] or
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'thread' in glib_sanitizers,
},
'async-close-output-stream' : {},
'async-splice-output-stream' : {},
'buffered-input-stream' : {},
'buffered-output-stream' : {},
'cancellable' : {},
'contexts' : {},
'contexts' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'contenttype' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392 / https://gitlab.gnome.org/GNOME/glib/-/issues/1251
'can_fail' : host_system == 'darwin',
@ -77,19 +82,24 @@ gio_tests = {
'error': {},
'file-thumbnail' : {},
'fileattributematcher' : {},
'filter-streams' : {},
'filter-streams' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'giomodule' : {
'depends' : glib_build_shared ? [libtestmodulea, libtestmoduleb] : [],
},
'gsubprocess' : {
'suite': host_system == 'windows' ? ['flaky'] : [],
'extra_programs': ['gsubprocess-testprog'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'g-file' : {},
'g-file-info' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3070
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
'can_fail' : host_system in ['darwin', 'gnu'] or host_system == 'windows' and cc.get_id() != 'gcc',
'can_fail' : host_system in ['darwin', 'gnu'] or host_system == 'windows' and not glib_gnu_cc_compiler,
},
'g-icon' : {},
'gdbus-addresses' : {},
@ -99,7 +109,9 @@ gio_tests = {
'install_rpath' : installed_tests_execdir,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
'can_fail' : host_system in ['darwin', 'windows', 'gnu'],
'can_fail' : host_system in ['darwin', 'windows', 'gnu'] or
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'thread' in glib_sanitizers,
},
'inet-address' : {},
'io-stream' : {},
@ -110,8 +122,14 @@ gio_tests = {
'memory-settings-backend' : {},
'mount-operation' : {},
'network-address' : {'extra_sources': ['mock-resolver.c']},
'network-monitor' : {},
'network-monitor-race' : {},
'network-monitor' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'network-monitor-race' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'null-settings-backend' : {},
'permission' : {},
'pollable' : {'dependencies' : [libutil_dep]},
@ -133,7 +151,10 @@ gio_tests = {
'socket-listener' : {},
'socket-service' : {},
'srvtarget' : {},
'task' : {},
'task' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'vfs' : {},
'volumemonitor' : {},
'glistmodel' : {},
@ -183,7 +204,9 @@ test_extra_programs = {
python_tests = {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/2764
'codegen.py' : {
'can_fail' : host_system == 'freebsd',
'can_fail' : host_system == 'freebsd' or
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'thread' in glib_sanitizers,
'suite': ['gdbus-codegen', 'slow'],
'timeout': 90,
},
@ -227,19 +250,27 @@ if dbus1_dep.found()
},
'gdbus-server-auth' : {
'dependencies' : [dbus1_dep],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
}
else
# We can build a cut-down version of this test without libdbus
gio_tests += {
'gdbus-server-auth' : {},
'gdbus-server-auth' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
}
endif
have_dbus_daemon = find_program('dbus-daemon', required : false).found()
if have_dbus_daemon
gio_tests += {
'debugcontroller' : {},
'debugcontroller' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'defaultvalue' : {'extra_sources' : [giotypefuncs_inc]},
}
endif
@ -249,10 +280,18 @@ if host_machine.system() != 'windows'
gio_tests += {
'file' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
'can_fail' : host_system == 'gnu',
'can_fail' : host_system == 'gnu' or
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'thread' in glib_sanitizers,
},
'gdbus-peer-object-manager' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-sasl' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-peer-object-manager' : {},
'gdbus-sasl' : {},
'live-g-file' : {},
'portal-support-flatpak-none' : {
'extra_sources': ['../gportalsupport.c', '../gsandbox.c', 'portal-support-utils.c'],
@ -302,37 +341,39 @@ if host_machine.system() != 'windows'
'unix-mounts' : {},
'unix-streams' : {},
'g-file-info-filesystem-readonly' : {},
'gschema-compile' : {'install' : false},
'gschema-compile' : {
'install' : false,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'trash' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3069
'can_fail' : host_system == 'darwin',
'can_fail' : host_system == 'darwin' or
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'thread' in glib_sanitizers,
},
}
if have_rtld_next and glib_build_shared
asan_env = {}
if 'address' in glib_sanitizers
asan_env = {'ASAN_OPTIONS': 'verify_asan_link_order=0'}
endif
slow_connect_preload_lib = shared_library('slow-connect-preload',
'slow-connect-preload.c',
name_prefix : '',
dependencies: libdl_dep,
install_dir : installed_tests_execdir,
install_tag : 'tests',
install: installed_tests_enabled,
)
gio_tests += {
'gsocketclient-slow' : {
'depends' : [
shared_library('slow-connect-preload',
'slow-connect-preload.c',
name_prefix : '',
dependencies: libdl_dep,
install_dir : installed_tests_execdir,
install_tag : 'tests',
install: installed_tests_enabled,
)
],
'depends' : slow_connect_preload_lib,
'env' : {
'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(meson.current_build_dir())
} + asan_env,
glib_exec_var_preload: slow_connect_preload_lib.full_path(),
},
'installed_tests_env' : {
'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(installed_tests_execdir),
} + asan_env,
glib_exec_var_preload: installed_tests_execdir /
fs.name(slow_connect_preload_lib.full_path()),
},
},
}
endif
@ -344,13 +385,17 @@ if host_machine.system() != 'windows'
'appinfo' : {
'install' : false,
'extra_programs' : ['appinfo-test'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'desktop-app-info' : {
'install' : false,
'depends' : gio_launch_desktop,
'extra_programs' : ['apps', 'appinfo-test'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
'can_fail' : host_system == 'gnu',
'can_fail' : host_system == 'gnu' or
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'thread' in glib_sanitizers,
},
}
endif
@ -446,78 +491,129 @@ if host_machine.system() != 'windows'
'actions' : {
'extra_sources' : extra_sources,
'suite' : ['slow'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'fdo-notification-backend': {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-auth' : {
'extra_sources' : extra_sources,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'fdo-notification-backend': {},
'gdbus-auth' : {'extra_sources' : extra_sources},
'gdbus-bz627724' : {'extra_sources' : extra_sources},
'gdbus-close-pending' : {'extra_sources' : extra_sources},
'gdbus-close-pending' : {
'extra_sources' : extra_sources,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-connection' : {
'extra_sources' : extra_sources,
'extra_programs': extra_programs,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-connection-loss' : {
'extra_sources' : extra_sources,
'extra_programs': extra_programs,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-connection-slow' : {
'extra_sources' : extra_sources,
'extra_programs': extra_programs + ['gdbus-connection-flush-helper'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
'can_fail' : host_system == 'gnu',
'can_fail' : host_system == 'gnu' or
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'thread' in glib_sanitizers,
},
'gdbus-error' : {'extra_sources' : extra_sources},
'gdbus-exit-on-close' : {'extra_sources' : extra_sources},
'gdbus-exit-on-close' : {
'extra_sources' : extra_sources,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-export' : {
'extra_sources' : extra_sources,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
'suite' : ['slow'],
},
'gdbus-introspection' : {
'extra_sources' : extra_sources,
'extra_programs': extra_programs,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-method-invocation' : {
'extra_sources' : extra_sources,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-method-invocation' : {'extra_sources' : extra_sources},
'gdbus-names' : {
'extra_sources' : extra_sources,
'extra_programs' : ['fake-service-name'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-proxy' : {
'extra_sources' : extra_sources,
'extra_programs': extra_programs,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-proxy-threads' : {
'extra_sources' : extra_sources,
'dependencies' : [dbus1_dep],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
'can_fail' : host_system == 'gnu',
'can_fail' : host_system == 'gnu' or
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'thread' in glib_sanitizers,
},
'gdbus-proxy-unique-name' : {
'extra_sources' : extra_sources,
'extra_programs': extra_programs,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-proxy-well-known-name' : {
'extra_sources' : extra_sources,
'extra_programs': extra_programs,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-subscribe' : {
'extra_sources' : extra_sources,
'extra_programs': extra_programs,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-test-codegen' : {
'extra_sources' : [extra_sources, gdbus_test_codegen_generated, gdbus_test_codegen_generated_interface_info],
'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32'],
'suite': ['gdbus-codegen'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-threading' : {
'extra_sources' : extra_sources,
'extra_programs': extra_programs,
'suite' : ['slow'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gmenumodel' : {
'extra_sources' : extra_sources,
'suite' : ['slow'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gnotification' : {
'extra_sources' : [extra_sources, 'gnotification-server.c'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-test-codegen-old' : {
'source' : 'gdbus-test-codegen.c',
@ -525,16 +621,22 @@ if host_machine.system() != 'windows'
'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36',
'-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36'],
'suite': ['gdbus-codegen'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-test-codegen-min-required-2-64' : {
'source' : 'gdbus-test-codegen.c',
'extra_sources' : [extra_sources, gdbus_test_codegen_generated_min_required_2_64, gdbus_test_codegen_generated_interface_info],
'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_64'],
'suite': ['gdbus-codegen'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gapplication' : {
'extra_sources' : extra_sources,
'extra_programs': ['basic-application'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
}
@ -543,6 +645,8 @@ if host_machine.system() != 'windows'
'dbus-appinfo' : {
'extra_sources' : extra_sources,
'extra_programs' : ['fake-document-portal'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
}
endif
@ -579,9 +683,13 @@ if host_machine.system() != 'windows'
gio_tests += {
'gdbus-connection-flush' : {
'extra_sources' : ['test-io-stream.c', 'test-pipe-unix.c'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'gdbus-non-socket' : {
'extra_sources' : ['gdbus-tests.c', 'test-io-stream.c', 'test-pipe-unix.c'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
}
@ -597,7 +705,9 @@ if host_machine.system() != 'windows'
'install' : false,
'depends' : glib_compile_schemas,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
'can_fail' : host_system == 'gnu',
'can_fail' : host_system == 'gnu' or
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'thread' in glib_sanitizers,
},
}
endif
@ -1001,7 +1111,7 @@ if not meson.is_cross_build()
'-nostdlib', '@INPUT@', '-o','@OUTPUT@'])
# Rename symbol to match the one in the C file
if cc.get_id() == 'gcc' and host_system == 'windows'
if glib_gnu_cc_compiler and host_system == 'windows'
underscore = '_'
else
underscore = ''
@ -1067,9 +1177,18 @@ foreach test_name, extra_args : gio_tests
test_conf.set('program', test_name)
test_env_override = ''
if installed_tests_env != {}
if installed_tests_env.has_key(glib_exec_var_preload)
installed_tests_env += {
'ASAN_OPTIONS': ','.join([
glib_exec_asan_option_ignore_preload,
installed_tests_env.get('ASAN_OPTIONS', ''),
]),
}
endif
envs = []
foreach var, value : installed_tests_env
envs += '@0@=@1@'.format(var, value)
envs += '@0@=\'@1@\''.format(var, value)
endforeach
test_env_override = '@0@ @1@ '.format(env_program.full_path(), ' '.join(envs))
endif
@ -1102,7 +1221,26 @@ foreach test_name, extra_args : gio_tests
depends += test_extra_programs_targets[program]
endforeach
foreach var, value : extra_args.get('env', {})
local_test_env_args = extra_args.get('env', {})
if local_test_env_args.has_key(glib_exec_var_preload)
if glib_exec_preloaded_env.has_key(glib_exec_var_preload)
local_test_env_args += {
glib_exec_var_preload: glib_exec_var_preload_separator.join([
glib_exec_preloaded_env.get(glib_exec_var_preload),
local_test_env_args.get(glib_exec_var_preload),
])
}
else
local_test_env_args += {
'ASAN_OPTIONS': ','.join([
glib_exec_asan_option_ignore_preload,
local_test_env_args.get('ASAN_OPTIONS', ''),
]),
}
endif
endif
foreach var, value : local_test_env_args
local_test_env.append(var, value)
endforeach

View File

@ -219,6 +219,7 @@ main (int argc, char **argv)
g_fprintf (stderr, "%s\n", message);
g_free (message);
gi_ir_parser_free (parser);
g_error_free (error);
return 1;
}
@ -229,6 +230,7 @@ main (int argc, char **argv)
{
GITypelib *typelib = NULL;
int write_successful;
if (shlibs)
{
@ -246,10 +248,14 @@ main (int argc, char **argv)
g_error (_("Invalid typelib for module %s: %s"),
module->name, error->message);
if (!write_out_typelib (NULL, typelib))
return 1;
write_successful = write_out_typelib (NULL, typelib);
g_clear_pointer (&typelib, gi_typelib_unref);
if (!write_successful)
{
gi_ir_parser_free (parser);
return 1;
}
}
g_debug ("[building] done");

View File

@ -2243,7 +2243,7 @@ end_type_top (ParseContext *ctx)
if (!ctx->type_parameters)
goto out;
typenode = (GIIrNodeType*)ctx->type_parameters->data;
typenode = (GIIrNodeType*) g_steal_pointer (&ctx->type_parameters->data);
/* Default to pointer for unspecified containers */
if (typenode->tag == GI_TYPE_TAG_ARRAY ||
@ -2292,7 +2292,7 @@ end_type_top (ParseContext *ctx)
g_printerr("current node is %d\n", CURRENT_NODE (ctx)->type);
g_assert_not_reached ();
}
g_list_free (ctx->type_parameters);
g_list_free_full (ctx->type_parameters, (GDestroyNotify) gi_ir_node_free);
out:
ctx->type_depth = 0;
@ -2308,7 +2308,7 @@ end_type_recurse (ParseContext *ctx)
parent = (GIIrNodeType *) ((GList*)ctx->type_stack->data)->data;
if (ctx->type_parameters)
param = (GIIrNodeType *) ctx->type_parameters->data;
param = (GIIrNodeType *) g_steal_pointer (&ctx->type_parameters->data);
if (parent->tag == GI_TYPE_TAG_ARRAY ||
parent->tag == GI_TYPE_TAG_GLIST ||
@ -2317,7 +2317,7 @@ end_type_recurse (ParseContext *ctx)
g_assert (param != NULL);
if (parent->parameter_type1 == NULL)
parent->parameter_type1 = param;
parent->parameter_type1 = g_steal_pointer (&param);
else
g_assert_not_reached ();
}
@ -2326,13 +2326,14 @@ end_type_recurse (ParseContext *ctx)
g_assert (param != NULL);
if (parent->parameter_type1 == NULL)
parent->parameter_type1 = param;
parent->parameter_type1 = g_steal_pointer (&param);
else if (parent->parameter_type2 == NULL)
parent->parameter_type2 = param;
parent->parameter_type2 = g_steal_pointer (&param);
else
g_assert_not_reached ();
}
g_list_free (ctx->type_parameters);
g_clear_pointer ((GIIrNode **) &param, gi_ir_node_free);
g_list_free_full (ctx->type_parameters, (GDestroyNotify) gi_ir_node_free);
ctx->type_parameters = (GList *)ctx->type_stack->data;
ctx->type_stack = g_list_delete_link (ctx->type_stack, ctx->type_stack);
}

View File

@ -19,9 +19,19 @@ gi_gen_shared_dependencies = [
gi_gen_env_variables = environment()
# Use currently built libraries to run g-ir-scanner and the various tools
# this may not happen if we don't set the library paths.
# This seems to break thread sanitizer though, so let's ignore it for now.
if 'thread' not in glib_sanitizers
gi_gen_env_variables.prepend(glib_exec_var_library_path,
fs.parent(libglib.full_path()), fs.parent(libgobject.full_path()),
fs.parent(libgmodule.full_path()), fs.parent(libgio.full_path()))
endif
if 'address' in glib_sanitizers
gi_gen_env_variables.append(
'ASAN_OPTIONS', 'verify_asan_link_order=0', separator: ',')
gi_gen_env_variables.append('ASAN_OPTIONS',
glib_exec_asan_options_disable,
separator: ',')
endif
if host_system == 'windows'

View File

@ -247,9 +247,9 @@ if enable_gir
subdir('introspection')
endif
subdir('decompiler')
subdir('inspector')
if build_tests
subdir('tests')
endif
subdir('decompiler')
subdir('inspector')

View File

@ -102,9 +102,18 @@ foreach test_name, extra_args : girepository_tests
test_conf.set('program', test_name)
test_env_override = ''
if installed_tests_env != {}
if installed_tests_env.has_key(glib_exec_var_preload)
installed_tests_env += {
'ASAN_OPTIONS': ','.join([
glib_exec_asan_option_ignore_preload,
installed_tests_env.get('ASAN_OPTIONS', ''),
]),
}
endif
envs = []
foreach var, value : installed_tests_env
envs += '@0@=@1@'.format(var, value)
envs += '@0@=\'@1@\''.format(var, value)
endforeach
test_env_override = '@0@ @1@ '.format(env_program.full_path(), ' '.join(envs))
endif
@ -144,7 +153,26 @@ foreach test_name, extra_args : girepository_tests
endforeach
local_test_env = test_env
foreach var, value : extra_args.get('env', {})
local_test_env_args = extra_args.get('env', {})
if local_test_env_args.has_key(glib_exec_var_preload)
if glib_exec_preloaded_env.has_key(glib_exec_var_preload)
local_test_env_args += {
glib_exec_var_preload: glib_exec_var_preload_separator.join([
glib_exec_preloaded_env.get(glib_exec_var_preload),
local_test_env_args.get(glib_exec_var_preload),
])
}
else
local_test_env_args += {
'ASAN_OPTIONS': ','.join([
glib_exec_asan_option_ignore_preload,
local_test_env_args.get('ASAN_OPTIONS', ''),
]),
}
endif
endif
foreach var, value : local_test_env_args
local_test_env.append(var, value)
endforeach
@ -158,3 +186,83 @@ foreach test_name, extra_args : girepository_tests
should_fail: extra_args.get('should_fail', false),
)
endforeach
if enable_gir
test('gir-compiler-glib-open-failure', gicompilerepository,
args: [
'this-is' / 'not' / 'a-file.gir',
'--output', meson.current_build_dir() / 'invalid.typelib',
],
should_fail: true,
suite: ['girepository', 'compiler'],
)
test('gir-compiler-glib-write-failure', gicompilerepository,
args: [
glib_gir[0],
'--output', 'this-is' / 'not' / 'a-good-output' / 'invalid.typelib',
],
depends: glib_gir[0],
should_fail: true,
suite: ['girepository', 'compiler'],
)
endif
# When sanitizers are enabled we want to test the compiler memory is properly handled
if enable_gir and glib_sanitizers.length() > 0
gir_files = {
'glib': glib_gir,
'gobject': gobject_gir,
'gmodule': gmodule_gir,
'gio': gio_gir,
}
if host_system != 'windows'
gir_files += {'glib-unix': glib_unix_gir}
gir_files += {'gio-unix': gio_unix_gir}
else
gir_files += {'glib-win32': glib_win32_gir}
gir_files += {'gio-win32': gio_win32_gir}
endif
foreach name, g: gir_files
gir = g[0]
test('gir-compiler-' + name, gicompilerepository,
args: [
gir,
'--output', meson.current_build_dir() / name + '.typelib',
],
depends: gir,
suite: ['girepository', 'compiler'],
)
typelib = g[1]
typelib_name = fs.stem(typelib.full_path())
test('gi-inspect-typelib-' + name, giinspecttypelib,
args: [
'--print-typelibs',
'--print-shlibs',
typelib_name.split('-')[0],
'--typelib-version='+typelib_name.split('-')[-1],
],
env: {
'GI_TYPELIB_PATH': fs.parent(typelib.full_path()),
},
depends: typelib,
suite: ['girepository', 'inspector'],
)
endforeach
endif
test('gi-inspect-typelib-not-found', giinspecttypelib,
args: [
'--print-typelibs',
'--print-shlibs',
'AnInvalidNameSpace'
],
env: {
'GI_TYPELIB_PATH': meson.current_build_dir(),
},
should_fail: true,
suite: ['girepository', 'inspector'],
)

View File

@ -26,6 +26,7 @@
#include "garray.h"
#include "genviron.h"
#include "ghash.h"
#include "glib-private.h"
#include "gmessages.h"
#include "gstrfuncs.h"
#include "gthread.h"
@ -807,6 +808,7 @@ g_get_language_names_with_category (const gchar *category_name)
cache = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, language_names_cache_free);
g_private_set (&cache_private, cache);
g_ignore_leak (cache);
}
languages = guess_category_value (category_name);
@ -835,6 +837,7 @@ g_get_language_names_with_category (const gchar *category_name)
name_cache->languages = g_strdup (languages);
name_cache->language_names = (gchar **) g_ptr_array_free (array, FALSE);
g_hash_table_insert (cache, g_strdup (category_name), name_cache);
g_ignore_leak (name_cache);
}
return (const gchar * const *) name_cache->language_names;

View File

@ -99,7 +99,7 @@ g_leak_sanitizer_is_supported (void)
#if defined (_GLIB_ADDRESS_SANITIZER)
return TRUE;
#elif defined (HAS_DYNAMIC_ASAN_LOADING)
return __lsan_enable != NULL && __lsan_ignore_object != NULL;
return G_UNLIKELY (__lsan_enable != NULL && __lsan_ignore_object != NULL);
#else
return FALSE;
#endif
@ -121,7 +121,7 @@ g_ignore_leak (gconstpointer p)
if (p != NULL)
__lsan_ignore_object (p);
#elif defined (HAS_DYNAMIC_ASAN_LOADING)
if (p != NULL && __lsan_ignore_object != NULL)
if (G_LIKELY (p != NULL) && G_UNLIKELY (__lsan_ignore_object != NULL))
__lsan_ignore_object (p);
#endif
}
@ -165,7 +165,7 @@ g_begin_ignore_leaks (void)
#if defined (_GLIB_ADDRESS_SANITIZER)
__lsan_disable ();
#elif defined (HAS_DYNAMIC_ASAN_LOADING)
if (__lsan_disable != NULL)
if (G_UNLIKELY (__lsan_disable != NULL))
__lsan_disable ();
#endif
}
@ -182,7 +182,7 @@ g_end_ignore_leaks (void)
#if defined (_GLIB_ADDRESS_SANITIZER)
__lsan_enable ();
#elif defined (HAS_DYNAMIC_ASAN_LOADING)
if (__lsan_enable != NULL)
if (G_UNLIKELY (__lsan_enable != NULL))
__lsan_enable ();
#endif
}

View File

@ -42,6 +42,7 @@
#include "gthread.h"
#include "gthreadprivate.h"
#include "glib-private.h"
#include <string.h>
@ -448,10 +449,10 @@ static GPrivate g_thread_specific_private = G_PRIVATE_INIT (g_thread_cleanup
*
* Sets the thread local variable @key to have a newly-allocated and zero-filled
* value of given @size, and returns a pointer to that memory. Allocations made
* using this API will be suppressed in valgrind: it is intended to be used for
* one-time allocations which are known to be leaked, such as those for
* per-thread initialisation data. Otherwise, this function behaves the same as
* g_private_set().
* using this API will be suppressed in valgrind and leak sanitizer: it is
* intended to be used for one-time allocations which are known to be leaked,
* such as those for per-thread initialisation data. Otherwise, this function
* behaves the same as g_private_set().
*
* Returns: (transfer full): new thread-local heap allocation of size @size
* Since: 2.60
@ -463,6 +464,7 @@ g_private_set_alloc0 (GPrivate *key,
{
gpointer allocated = g_malloc0 (size);
g_ignore_leak (allocated);
g_private_set (key, allocated);
return g_steal_pointer (&allocated);

View File

@ -2,7 +2,7 @@ glib_tests = {
'array-test' : {},
'asyncqueue' : {},
'atomic' : {
'c_args' : cc.get_id() == 'gcc' ? ['-Wstrict-aliasing=2'] : [],
'c_args' : glib_gnu_cc_compiler ? ['-Wstrict-aliasing=2'] : [],
'c_standards': c_standards.keys(),
},
'base64' : {},
@ -81,9 +81,15 @@ glib_tests = {
'link_args' : cc.get_id() == 'gcc' and cc.version().version_compare('> 6')
? ['-Wno-alloc-size-larger-than'] : [],
},
'mutex' : {},
'mutex' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'node' : {},
'once' : {},
'once' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'onceinit' : {},
'option-context' : {
# musl: /option/arg/repetition/locale should be skipped but it's not. The
@ -103,7 +109,10 @@ glib_tests = {
'queue' : {},
'rand' : {},
'rcbox' : {},
'rec-mutex' : {},
'rec-mutex' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'refcount' : {},
'refcount-macro' : {
'source' : 'refcount.c',
@ -126,7 +135,9 @@ glib_tests = {
'slist' : {},
'sort' : {},
'spawn-multithreaded' : {
'can_fail': glib_build_static and host_system == 'windows',
'can_fail': glib_build_static and host_system == 'windows' or
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'thread' in glib_sanitizers,
'suite': host_system == 'windows' ? ['flaky'] : [],
'extra_programs' : ['test-spawn-echo'] + (
host_machine.system() == 'windows' ? ['test-spawn-sleep'] : []),
@ -151,17 +162,23 @@ glib_tests = {
},
'strfuncs' : {},
'string' : {
'c_args' : cc.get_id() == 'gcc' ? ['-Werror=sign-conversion'] : [],
'c_args' : glib_gnu_cc_compiler ? ['-Werror=sign-conversion'] : [],
},
'strvbuilder' : {},
'testing' : {
'args': [ '--verbose' ],
'extra_programs' : ['testing-helper'],
'c_args' : cc.get_id() == 'gcc' ? ['-Werror=sign-conversion'] : [],
'c_args' : glib_gnu_cc_compiler ? ['-Werror=sign-conversion'] : [],
},
'test-printf' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'test-printf' : {},
'thread' : {},
'thread-deprecated' : {},
'thread-deprecated' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'thread-pool' : {},
'thread-pool-slow' : {'suite' : ['slow']},
'timeout' : {},
@ -170,7 +187,7 @@ glib_tests = {
'types' : {},
'utf8-performance' : {},
'utf8-pointer' : {
'c_args' : cc.get_id() == 'gcc' ? ['-Werror=cast-qual'] : [],
'c_args' : glib_gnu_cc_compiler ? ['-Werror=cast-qual'] : [],
},
'utf8-validate' : {},
'utf8-misc' : {},
@ -182,12 +199,17 @@ glib_tests = {
'unicode-encoding' : {},
'unicode-normalize': {},
'uri' : {},
'1bit-mutex' : {},
'1bit-mutex' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'1bit-emufutex' : {
'source' : '1bit-mutex.c',
'c_args' : ['-DTEST_EMULATED_FUTEX'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3359
'can_fail': 'undefined' in glib_sanitizers,
'can_fail': 'undefined' in glib_sanitizers or
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'thread' in glib_sanitizers,
'install' : false,
'suite' : ['slow'],
},
@ -230,6 +252,8 @@ if glib_conf.has('HAVE_EVENTFD')
'source' : ['gwakeuptest.c', '../gwakeup.c'],
'c_args' : ['-DTEST_EVENTFD_FALLBACK'],
'install' : false,
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
}
endif
@ -259,26 +283,15 @@ else
install_tag : 'tests',
install: installed_tests_enabled)
if host_system not in ['ios', 'darwin']
var_preload = 'LD_PRELOAD'
else
var_preload = 'DYLD_INSERT_LIBRARIES'
endif
asan_env = {}
if 'address' in glib_sanitizers
asan_env = {'ASAN_OPTIONS': 'verify_asan_link_order=0'}
endif
glib_tests += {
'gutils-user-database' : {
'depends' : getpwuid_preload,
'env' : {
var_preload: getpwuid_preload.full_path()
} + asan_env,
glib_exec_var_preload: getpwuid_preload.full_path(),
},
'installed_tests_env' : {
var_preload: installed_tests_execdir / fs.name(getpwuid_preload.full_path())
} + asan_env,
glib_exec_var_preload: installed_tests_execdir / fs.name(getpwuid_preload.full_path())
},
},
}
endif
@ -425,9 +438,18 @@ foreach test_name, extra_args : glib_tests
test_conf.set('program', test_name)
test_env_override = ''
if installed_tests_env != {}
if installed_tests_env.has_key(glib_exec_var_preload)
installed_tests_env += {
'ASAN_OPTIONS': ','.join([
glib_exec_asan_option_ignore_preload,
installed_tests_env.get('ASAN_OPTIONS', ''),
]),
}
endif
envs = []
foreach var, value : installed_tests_env
envs += '@0@=@1@'.format(var, value)
envs += '@0@=\'@1@\''.format(var, value)
endforeach
test_env_override = '@0@ @1@ '.format(env_program.full_path(), ' '.join(envs))
endif
@ -466,10 +488,29 @@ foreach test_name, extra_args : glib_tests
endforeach
local_test_env = test_env
foreach var, value : extra_args.get('env', {})
local_test_env_args = extra_args.get('env', {})
if local_test_env_args.has_key(glib_exec_var_preload)
if glib_exec_preloaded_env.has_key(glib_exec_var_preload)
local_test_env_args += {
glib_exec_var_preload: glib_exec_var_preload_separator.join([
glib_exec_preloaded_env.get(glib_exec_var_preload),
local_test_env_args.get(glib_exec_var_preload),
])
}
else
local_test_env_args += {
'ASAN_OPTIONS': ','.join([
glib_exec_asan_option_ignore_preload,
local_test_env_args.get('ASAN_OPTIONS', ''),
]),
}
endif
endif
foreach var, value : local_test_env_args
local_test_env.append(var, value)
endforeach
test(test_name, exe,
args: extra_args.get('args', []),
protocol : extra_args.get('protocol', test_protocol),
@ -501,6 +542,8 @@ if 'messages-low-memory' in test_extra_programs
python_tests += {
'messages-low-memory.py' : {
'extra_programs': ['messages-low-memory'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
}
endif
@ -514,7 +557,26 @@ foreach test_name, extra_args : python_tests
endif
local_test_env = test_env
foreach var, value : extra_args.get('env', {})
local_test_env_args = extra_args.get('env', {})
if local_test_env_args.has_key(glib_exec_var_preload)
if glib_exec_preloaded_env.has_key(glib_exec_var_preload)
local_test_env_args += {
glib_exec_var_preload: glib_exec_var_preload_separator.join([
glib_exec_preloaded_env.get(glib_exec_var_preload),
local_test_env_args.get(glib_exec_var_preload),
])
}
else
local_test_env_args += {
'ASAN_OPTIONS': ','.join([
glib_exec_asan_option_ignore_preload,
local_test_env_args.get('ASAN_OPTIONS', ''),
]),
}
endif
endif
foreach var, value : local_test_env_args
local_test_env.append(var, value)
endforeach

View File

@ -57,7 +57,10 @@ gobject_tests = {
'custom-dispatch' : {
'extra_objs' : extra_custom_dispatch_objs,
},
'qdata' : {},
'qdata' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'accumulator' : {
'source' : ['accumulator.c', marshalers_h, marshalers_c],
},
@ -78,15 +81,29 @@ gobject_tests = {
'references' : {},
'basic-signals' : {},
'singleton' : {},
'threadtests' : {},
'dynamictests' : {},
'binding' : {},
'threadtests' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'dynamictests' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'binding' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'bindinggroup' : {},
'properties' : {},
'properties-introspection' : {},
'properties-introspection' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'reference' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
'can_fail' : host_system == 'gnu',
'can_fail' : host_system == 'gnu' or
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'thread' in glib_sanitizers,
},
'flags' : {},
'value' : {},
@ -95,7 +112,11 @@ gobject_tests = {
'source' : 'private.c',
},
'closure' : {},
'closure-refcount' : { 'suite': ['slow'] },
'closure-refcount' : {
'suite': ['slow'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'object' : {},
'signal-handler' : {},
'ifaceproperties' : {},
@ -113,17 +134,28 @@ gobject_tests = {
]),
},
'objects-refcount2' : {'suite' : ['slow']},
'properties-refcount1' : {},
'properties-refcount1' : {
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'properties-refcount2' : {'suite' : ['slow']},
'properties-refcount3' : {'suite' : ['slow']},
'properties-refcount3' : {
'suite' : ['slow'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'properties-refcount4' : {},
'signals-refcount1' : {
'source' : 'signals-refcount.c',
'c_args' : ['-DTESTNUM=1'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'signals-refcount2' : {
'source' : 'signals-refcount.c',
'c_args' : ['-DTESTNUM=2'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
'signals-refcount3' : {
'source' : 'signals-refcount.c',
@ -132,6 +164,8 @@ gobject_tests = {
'signals-refcount4' : {
'source' : 'signals-refcount.c',
'c_args' : ['-DTESTNUM=4'],
# FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1672
'can_fail': 'thread' in glib_sanitizers,
},
}

View File

@ -547,8 +547,10 @@ foreach m : struct_members
endif
endforeach
glib_gnu_cc_compiler = cc.get_id() == 'gcc' or cc.get_id() == 'clang'
# Compiler flags
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
if glib_gnu_cc_compiler
warning_common_args = [
'-Wduplicated-branches',
'-Wimplicit-fallthrough',
@ -1759,7 +1761,7 @@ g_sizet_compatibility = {
# Do separate checks for gcc/clang (and ignore other compilers for now), since
# we need to explicitly pass -Werror to the compilers.
# FIXME: https://github.com/mesonbuild/meson/issues/5399
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
if glib_gnu_cc_compiler
foreach type_name, size_compatibility : g_sizet_compatibility
g_sizet_compatibility += { type_name: size_compatibility and
cc.compiles(
@ -2057,7 +2059,7 @@ if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl' or cc.links(atomictest, na
glib_conf.set('__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4', true)
endif
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
if glib_gnu_cc_compiler
sync_swap_test = '''
int main() {
int atomic = 2;
@ -2611,6 +2613,84 @@ gir_args = [
'--quiet',
]
glib_exec_preloaded_libs = []
glib_exec_preloaded_env = {}
if host_system in ['ios', 'darwin']
glib_exec_var_library_path = 'DYLD_LIBRARY_PATH'
glib_exec_var_preload = 'DYLD_INSERT_LIBRARIES'
glib_exec_var_preload_separator = ':'
else
glib_exec_var_library_path = 'LD_LIBRARY_PATH'
glib_exec_var_preload = 'LD_PRELOAD'
glib_exec_var_preload_separator = ' '
endif
glib_exec_asan_options_disable = []
glib_exec_asan_option_ignore_preload = ''
if 'address' in glib_sanitizers
# libasan needs to be the first in the preload list, and that we cant
# guarantee that, so we have to disable its link order checking when using
# LD_PRELOAD in tests.
glib_exec_asan_option_ignore_preload = 'verify_asan_link_order=false'
glib_exec_asan_options_disable = [
glib_exec_asan_option_ignore_preload,
'start_deactivated=true',
'detect_leaks=false',
]
endif
if glib_gnu_cc_compiler and host_system != 'windows'
test_preloaded_libs = []
if 'address' in glib_sanitizers
# ASAN has to be the first in list
test_preloaded_libs += 'asan'
endif
if 'undefined' in glib_sanitizers
test_preloaded_libs += 'ubsan'
endif
if 'leak' in glib_sanitizers
test_preloaded_libs += 'lsan'
endif
if 'thread' in glib_sanitizers
test_preloaded_libs += 'tsan'
endif
# FIXME: Ideally meson should handle this for us
# https://github.com/mesonbuild/meson/issues/13249
foreach libname: test_preloaded_libs
lib = run_command(cc,
'-print-file-name=lib@0@.so'.format(libname),
check: true,
).stdout().strip()
# Support linker script files
if run_command('grep', '-qI', '^INPUT', lib, check: false).returncode() == 0
out = run_command('cat', lib, check: true).stdout()
lib = out.split('(')[1].split(')')[0].strip()
endif
if lib != '' and lib[0] == '/'
message('Found @0@ library as @1@'.format(libname, lib))
glib_exec_preloaded_libs += '@0@'.format(files(lib)[0])
else
warning('No library found for ' + libname + ', sanitizers [' +
', '.join(glib_sanitizers) + '] executions may fail')
endif
endforeach
if glib_exec_preloaded_libs.length() > 0
glib_exec_preloaded_env = {
glib_exec_var_preload: glib_exec_var_preload_separator.join(
glib_exec_preloaded_libs),
}
endif
endif
pkg = import('pkgconfig')
windows = import('windows')
gnome = import('gnome')

View File

@ -28,6 +28,6 @@ test(
python,
args : ['-B', files('check-missing-install-tag.py')],
env : test_env,
suite : ['lint', 'no-valgrind'],
suite : ['lint', 'no-valgrind', 'no-tsan'],
protocol : 'tap',
)