From 2c94349e79ac6b5bfedd2d3437ee5f950ebe9cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 24 May 2024 18:00:55 +0200 Subject: [PATCH 01/14] ci: Ignore lcov errors on source missing When using dtrace some temporary files may be leaked as source files and this may lead to build issues such as geninfo: ERROR: unable to open /builds/GNOME/glib/_build/.dtrace-temp.ed1c5ba9.c: No such file or directory AFAIK there's no way to keep these temporary files around, so the only thing we can do is making lcov less strict about missing files. We can drop the special option from genhtml since it's using the same lcovrc file --- .gitlab-ci.yml | 6 ++++-- .gitlab-ci/coverage-docker.sh | 1 - .lcovrc | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 533b2c31c..3c5e5b19d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -194,9 +194,11 @@ 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 + --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 + --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/ diff --git a/.gitlab-ci/coverage-docker.sh b/.gitlab-ci/coverage-docker.sh index 6367f5e14..53a14a283 100755 --- a/.gitlab-ci/coverage-docker.sh +++ b/.gitlab-ci/coverage-docker.sh @@ -27,7 +27,6 @@ for path in _coverage/*.lcov; do done genhtml \ - --ignore-errors=source \ --config-file .lcovrc \ _coverage/*.lcov \ -o _coverage/coverage diff --git a/.lcovrc b/.lcovrc index 9107da270..cbed5ba13 100644 --- a/.lcovrc +++ b/.lcovrc @@ -13,4 +13,7 @@ lcov_branch_coverage = 1 lcov_excl_br_line = LCOV_EXCL_BR_LINE|g_return_if_fail|g_return_val_if_fail|g_assert|g_assert_|g_clear_ # Similarly for unreachable assertions. -lcov_excl_line = LCOV_EXCL_LINE|g_return_if_reached|g_return_val_if_reached|g_assert_not_reached \ No newline at end of file +lcov_excl_line = LCOV_EXCL_LINE|g_return_if_reached|g_return_val_if_reached|g_assert_not_reached + +# When using dtrace some temporary files may be leaked as source files +ignore_errors = source From 2665a34b3f9d3e1550b7b6386522b75049ea745e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 24 May 2024 18:53:34 +0200 Subject: [PATCH 02/14] ci: Update coverage files atomically Since we run tests in parallel we may end up rewriting the coverage info while running files acting on the same source files. The compiler can be smart though, so let's use the proper flag. Despite this, sometimes we may still end up into negative reports, so let's ignore them in CI since it's not worth breaking the build because of these coverage-parsing failures. --- .gitlab-ci.yml | 2 +- .lcovrc | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3c5e5b19d..4ea475a8f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -174,7 +174,7 @@ fedora-x86_64: stage: build needs: [] variables: - CFLAGS: "-coverage -ftest-coverage -fprofile-arcs" + CFLAGS: "-coverage -ftest-coverage -fprofile-arcs -fprofile-update=atomic" before_script: - !reference [".build-linux", "before_script"] - !reference [".with-git", "before_script"] diff --git a/.lcovrc b/.lcovrc index cbed5ba13..1800471b1 100644 --- a/.lcovrc +++ b/.lcovrc @@ -17,3 +17,6 @@ lcov_excl_line = LCOV_EXCL_LINE|g_return_if_reached|g_return_val_if_reached|g_as # When using dtrace some temporary files may be leaked as source files ignore_errors = source + +# Sometimes we may have negative counting despite using atomic profile update +ignore_errors = negative From 64f744523202954f2dea466b00110e851640bd1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 24 May 2024 18:54:54 +0200 Subject: [PATCH 03/14] ci: Actually use a fedora 39 image Also start using a more reliable versioning scheme for the fedora images so that the tag is always vFEDORA_VERSION.IMAGE_VERSION to make it easier to understand on future updates Fixes: #3381 --- .gitlab-ci.yml | 4 ++-- .gitlab-ci/mingw.Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4ea475a8f..aa706c123 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,11 +11,11 @@ cache: - _ccache/ variables: - FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v27" + FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v39.1" 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" - MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v16" + MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v39.1" MESON_TEST_TIMEOUT_MULTIPLIER: 4 G_MESSAGES_DEBUG: all MESON_COMMON_OPTIONS: "--buildtype debug --wrap-mode=nodownload --fatal-meson-warnings" diff --git a/.gitlab-ci/mingw.Dockerfile b/.gitlab-ci/mingw.Dockerfile index fde9550d0..64ad06e72 100644 --- a/.gitlab-ci/mingw.Dockerfile +++ b/.gitlab-ci/mingw.Dockerfile @@ -1,4 +1,4 @@ -FROM registry.gitlab.gnome.org/gnome/glib/fedora:v27 +FROM registry.gitlab.gnome.org/gnome/glib/fedora:v39.1 USER root @@ -14,4 +14,4 @@ WORKDIR /opt COPY cross_file_mingw64.txt /opt USER user -WORKDIR /home/user \ No newline at end of file +WORKDIR /home/user From b2c5092bf12652a0d8be9e7ca9f8c3f5431d90c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 24 May 2024 19:10:08 +0200 Subject: [PATCH 04/14] glib/tests/unix: Free fds before exiting Old valgrind wasn't spotting this but we're smarter now! --- glib/tests/unix.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/glib/tests/unix.c b/glib/tests/unix.c index c5d553aa4..c51963104 100644 --- a/glib/tests/unix.c +++ b/glib/tests/unix.c @@ -103,14 +103,18 @@ test_closefrom (void) if (flags == -1) { + int exit_code = 100 + fds[i]; async_signal_safe_message ("fd should not have been closed"); - _exit (100 + fds[i]); + g_free (fds); + _exit (exit_code); } if (flags & FD_CLOEXEC) { + int exit_code = 100 + fds[i]; async_signal_safe_message ("fd should not have been close-on-exec yet"); - _exit (100 + fds[i]); + g_free (fds); + _exit (exit_code); } } @@ -122,14 +126,18 @@ test_closefrom (void) if (flags == -1) { + int exit_code = 100 + fds[i]; async_signal_safe_message ("fd should not have been closed"); - _exit (100 + fds[i]); + g_free (fds); + _exit (exit_code); } if (!(flags & FD_CLOEXEC)) { + int exit_code = 100 + fds[i]; async_signal_safe_message ("fd should have been close-on-exec"); - _exit (100 + fds[i]); + g_free (fds); + _exit (exit_code); } } @@ -142,12 +150,14 @@ test_closefrom (void) if (flags == -1) { async_signal_safe_message ("fd should not have been closed"); + g_free (fds); _exit (100 + fd); } if (flags & FD_CLOEXEC) { async_signal_safe_message ("fd should not have been close-on-exec"); + g_free (fds); _exit (100 + fd); } } @@ -157,10 +167,12 @@ test_closefrom (void) if (fcntl (fds[i], F_GETFD) != -1 || errno != EBADF) { async_signal_safe_message ("fd should have been closed"); + g_free (fds); _exit (100 + fds[i]); } } + g_free (fds); _exit (0); } From d6a18eec81a2f6770171d99047dcbd3c8ee3eff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 24 May 2024 19:19:01 +0200 Subject: [PATCH 05/14] tools/glib.supp: Also ignore possible leaks on g_set_user_dirs() Newer valgrind is smarter so g_set_user_dirs() are now possible leaks --- tools/glib.supp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/glib.supp b/tools/glib.supp index 5e4fbd23e..6820e41c9 100644 --- a/tools/glib.supp +++ b/tools/glib.supp @@ -821,7 +821,7 @@ { g_set_user_dirs_str Memcheck:Leak - match-leak-kinds:definite,reachable + match-leak-kinds:definite,reachable,possible fun:malloc ... fun:set_str_if_different @@ -833,7 +833,7 @@ { g_set_user_dirs_strv Memcheck:Leak - match-leak-kinds:definite,reachable + match-leak-kinds:definite,reachable,possible fun:malloc ... fun:set_strv_if_different From c320bb0bf88a3b10dad9ac7bc9326bf4f03d12fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 24 May 2024 19:40:06 +0200 Subject: [PATCH 06/14] ci: Ignore unused patterns gnulib doesn't seem to be used at the moment so its _build folder, but let's still try and don't fail if that's not happening --- .lcovrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.lcovrc b/.lcovrc index 1800471b1..b7bc78b6c 100644 --- a/.lcovrc +++ b/.lcovrc @@ -20,3 +20,6 @@ ignore_errors = source # Sometimes we may have negative counting despite using atomic profile update ignore_errors = negative + +# gnulib paths may not be used +ignore_errors = unused From a04340a742997476ca5f728b82c93628940e3f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 2 Aug 2024 11:00:44 +0200 Subject: [PATCH 07/14] ci/fixup-cov-paths: Ensure path replacement still works Without doing this we were replacing the paths with the glib subfolder, pointing to the wrong files. --- .gitlab-ci/fixup-cov-paths.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci/fixup-cov-paths.py b/.gitlab-ci/fixup-cov-paths.py index 5fb77c64a..98795fba3 100644 --- a/.gitlab-ci/fixup-cov-paths.py +++ b/.gitlab-ci/fixup-cov-paths.py @@ -13,6 +13,7 @@ def main(argv): print("cov-fixup:", path) text = io.open(path, "r", encoding="utf-8").read() text = text.replace("\\\\", "/") + text = text.replace("\\", "/") old_root = re.search(":(.*?)/glib/.*?$", text, re.MULTILINE).group(1) new_root = os.path.dirname(os.getcwd()) if old_root != new_root: From 447ebe16afd3b013f186409811512261356e1374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 2 Aug 2024 08:58:19 +0200 Subject: [PATCH 08/14] ci/coverage: Remove coverage from all subprojects --- .gitlab-ci/coverage-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci/coverage-docker.sh b/.gitlab-ci/coverage-docker.sh index 53a14a283..a180ebf08 100755 --- a/.gitlab-ci/coverage-docker.sh +++ b/.gitlab-ci/coverage-docker.sh @@ -13,7 +13,7 @@ for path in _coverage/*.lcov; do # Remove coverage from the fuzz tests, since they are run on a separate CI system lcov --config-file .lcovrc -r "${path}" "*/fuzzing/*" -o "$(pwd)/${path}" # Remove coverage from copylibs and subprojects - for lib in xdgmime libcharset gnulib; do + for lib in xdgmime libcharset gnulib subprojects; do lcov --config-file .lcovrc -r "${path}" "*/${lib}/*" -o "$(pwd)/${path}" done From 0f8971472cbc616528e197c5e97dfcde96bf2e23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 2 Aug 2024 10:24:01 +0200 Subject: [PATCH 09/14] ci/coverage: Help genhtml to define the common prefix --- .gitlab-ci/coverage-docker.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci/coverage-docker.sh b/.gitlab-ci/coverage-docker.sh index a180ebf08..2c21c67a0 100755 --- a/.gitlab-ci/coverage-docker.sh +++ b/.gitlab-ci/coverage-docker.sh @@ -27,6 +27,7 @@ for path in _coverage/*.lcov; do done genhtml \ + --prefix "$PWD" \ --config-file .lcovrc \ _coverage/*.lcov \ -o _coverage/coverage From f2993b10df1bcbb5c4b637429f760c2724ef1da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 2 Aug 2024 13:55:49 +0200 Subject: [PATCH 10/14] ci/coverage: Fix link of coverage index page Use $CI_JOB_ID as $CI_BUILD_ID is undefined --- .gitlab-ci/coverage-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci/coverage-docker.sh b/.gitlab-ci/coverage-docker.sh index 2c21c67a0..daccce950 100755 --- a/.gitlab-ci/coverage-docker.sh +++ b/.gitlab-ci/coverage-docker.sh @@ -46,4 +46,4 @@ cat >index.html < Date: Fri, 2 Aug 2024 13:49:51 +0200 Subject: [PATCH 11/14] ci: Ignore empty lcov files such as the baselines ones --- .lcovrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.lcovrc b/.lcovrc index b7bc78b6c..e64b52ce6 100644 --- a/.lcovrc +++ b/.lcovrc @@ -23,3 +23,6 @@ ignore_errors = negative # gnulib paths may not be used ignore_errors = unused + +# baseline lcov files may be empty +ignore_errors = empty From 24ec28a9a64b485bd71e14ae18bf64afe93d312e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 24 Jul 2024 10:44:03 +0200 Subject: [PATCH 12/14] tools/glib.supp: Ignore valgrind false-positive error on wcsxfrm See: https://gitlab.gnome.org/GNOME/glib/-/issues/3292 --- tools/glib.supp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/glib.supp b/tools/glib.supp index 6820e41c9..5c3740574 100644 --- a/tools/glib.supp +++ b/tools/glib.supp @@ -1322,3 +1322,13 @@ fun:g_rw_lock_writer_lock fun:g_log_writer_default_set_debug_domains } + +# This can be removed when versions of valgrind including the fix are widely used. +# See https://gitlab.gnome.org/GNOME/glib/-/issues/3292 +{ + g_utf8_collate_key wcsxfrm false-positive + Memcheck:Addr32 + ... + fun:wcsxfrm* + fun:g_utf8_collate_key +} From 2f938054e9817e67472724d11ea00210a82a4510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 24 Jul 2024 11:34:44 +0200 Subject: [PATCH 13/14] ci: Also compile C++ files with coverage collection --- .gitlab-ci.yml | 3 ++- .lcovrc | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aa706c123..cbb29c8eb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -174,7 +174,8 @@ fedora-x86_64: stage: build needs: [] variables: - CFLAGS: "-coverage -ftest-coverage -fprofile-arcs -fprofile-update=atomic" + CFLAGS: "--coverage -ftest-coverage -fprofile-arcs -fprofile-update=atomic" + CXXFLAGS: "--coverage -ftest-coverage -fprofile-arcs -fprofile-update=atomic" before_script: - !reference [".build-linux", "before_script"] - !reference [".with-git", "before_script"] diff --git a/.lcovrc b/.lcovrc index e64b52ce6..353d49f43 100644 --- a/.lcovrc +++ b/.lcovrc @@ -4,6 +4,10 @@ # Always enable branch coverage lcov_branch_coverage = 1 +# Disable exception branch for C++: +# https://github.com/linux-test-project/lcov/issues/209 +no_exception_branch = 1 + # Exclude precondition assertions, as we can never reasonably get full branch # coverage of them, as they should never normally fail. # Similarly exclude g_clear_*() functions (such as g_clear_object(), From 6c679fb37a0bfeed7beb42d1b1e3590713eac10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 24 Jul 2024 12:10:04 +0200 Subject: [PATCH 14/14] gcancellable: Mark assert-only variable as unused --- gio/gcancellable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gio/gcancellable.c b/gio/gcancellable.c index abf5878ed..27dd06370 100644 --- a/gio/gcancellable.c +++ b/gio/gcancellable.c @@ -664,7 +664,7 @@ cancellable_source_cancelled (GCancellable *cancellable, { GSource *source = user_data; GCancellableSource *cancellable_source = (GCancellableSource *) source; - gboolean callback_was_not_called; + gboolean callback_was_not_called G_GNUC_UNUSED; g_source_ref (source); g_source_set_ready_time (source, 0);