From 0e3fabe6976827ba6d4bded06cbe325dcd001cba Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 14 Aug 2025 10:00:16 +1000 Subject: [PATCH 1/9] msan: update motd message for developer use --- .github/workflows/build-debian.msan-based.yml | 5 +- ci_build_images/msan.fragment.Dockerfile | 47 ++--------------- ci_build_images/msan.motd | 52 +++++++++++++++++++ 3 files changed, 59 insertions(+), 45 deletions(-) create mode 100644 ci_build_images/msan.motd diff --git a/.github/workflows/build-debian.msan-based.yml b/.github/workflows/build-debian.msan-based.yml index ef0064e10..799b44059 100644 --- a/.github/workflows/build-debian.msan-based.yml +++ b/.github/workflows/build-debian.msan-based.yml @@ -10,6 +10,7 @@ on: - 'ci_build_images/rr.Dockerfile' - 'ci_build_images/msan.fragment.Dockerfile' - 'ci_build_images/msan.instrumentedlibs.sh' + - 'ci_build_images/msan.motd' - 'ci_build_images/qpress.Dockerfile' - 'ci_build_images/buildbot-worker.Dockerfile' - .github/workflows/build-debian.msan-based.yml @@ -20,6 +21,7 @@ on: - 'ci_build_images/rr.Dockerfile' - 'ci_build_images/msan.fragment.Dockerfile' - 'ci_build_images/msan.instrumentedlibs.sh' + - 'ci_build_images/msan.motd' - 'ci_build_images/qpress.Dockerfile' - 'ci_build_images/buildbot-worker.Dockerfile' - .github/workflows/build-debian.msan-based.yml @@ -50,6 +52,7 @@ jobs: nogalera: ${{ matrix.nogalera }} files: '[ - {"name": "msan.instrumentedlibs.sh", "source": "''$WORKDIR/msan.instrumentedlibs.sh''", "target": "''$GITHUB_WORKSPACE''"} + {"name": "msan.instrumentedlibs.sh", "source": "''$WORKDIR/msan.instrumentedlibs.sh''", "target": "''$GITHUB_WORKSPACE''"}, + {"name": "msan.motd", "source": "''$WORKDIR/msan.motd''", "target": "''$GITHUB_WORKSPACE''"} ]' secrets: inherit diff --git a/ci_build_images/msan.fragment.Dockerfile b/ci_build_images/msan.fragment.Dockerfile index c7b3c394a..63fce8870 100644 --- a/ci_build_images/msan.fragment.Dockerfile +++ b/ci_build_images/msan.fragment.Dockerfile @@ -93,51 +93,10 @@ RUN . /etc/os-release \ COPY --from=rr /tmp/install/usr/ /usr/ # ASAN/UBSAN +COPY msan.motd /etc/motd + RUN echo "cat /etc/motd" > ~buildbot/.bashrc ; \ - printf "\ -This is a container for ASAN, UBSAN and MSAN building\n\ -\n\ -A basic MSAN build can be achieved with\n\ -\n\ -cmake -DWITH_EMBEDDED_SERVER=OFF \\ \n\ - -DWITH_INNODB_{BZIP2,LZ4,LZMA,LZO,SNAPPY}=OFF \\ \n\ - -DPLUGIN_{MROONGA,ROCKSDB,OQGRAPH,SPIDER}=NO \\ \n\ - -DWITH_ZLIB=bundled \\ \n\ - -DHAVE_LIBAIO_H=0 \\ \n\ - -DCMAKE_DISABLE_FIND_PACKAGE_{URING,LIBAIO}=1 \\ \n\ - -DWITH_NUMA=NO \\ \n\ - -DWITH_SYSTEMD=no \\ \n\ - -DWITH_MSAN=ON \\ \n\ - -DHAVE_CXX_NEW=1 \\ \n\ - -DCMAKE_{EXE,MODULE}_LINKER_FLAGS=\"-L\${MSAN_LIBDIR} -Wl,-rpath=\${MSAN_LIBDIR}\" \\ \n\ - -DWITH_DBUG_TRACE=OFF \\ \n\ - /source\n\ -\n\ -A basic combined UBSAN/ASAN build can be achieved with\n\ -\n\ -cmake -DWITH_ASAN=ON -DWITH_ASAN_SCOPED=ON -DWITH_UBSAN=ON -DPLUGIN_PERFSCHEMA=NO /source\n\ -\n\ -Build with:\n\ -\n\ -cmake --build .\n\ -\n\ -Test with:\n\ -\n\ -mysql-test/mtr --parallel=auto\n\ -\n\ -There are UBSAN filters covering currently unfixed bugs within\n\ -the server that can be used to direct your development, or validate if a\n\ -observed failure is known. Perform the following to download/inspect them.\n\ -\n\ -curl https://raw.githubusercontent.com/mariadb-corporation/mariadb-qa/refs/heads/master/UBSAN.filter -o /build/UBSAN.filter\n\ -\n\ -After this, add suppressions to UBSAN_OPTIONS with\n\ -\n\ -export UBSAN_OPTIONS=\$UBSAN_OPTIONS:suppressions=/build/UBSAN.filter\n\ -\n\ -ref sanitizer flags documents:\n\ -* https://github.com/google/sanitizers/wiki/AddressSanitizerFlags\n\ -* https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html\n\n" > /etc/motd + chown buildbot: ~buildbot/.bashrc ENV ASAN_OPTIONS=quarantine_size_mb=512:atexit=0:detect_invalid_pointer_pairs=3:dump_instruction_bytes=1:allocator_may_return_null=1 ENV UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1 diff --git a/ci_build_images/msan.motd b/ci_build_images/msan.motd new file mode 100644 index 000000000..fede90252 --- /dev/null +++ b/ci_build_images/msan.motd @@ -0,0 +1,52 @@ +This is a container for ASAN, UBSAN and MSAN building. + +It can also be used as a basic build/test that contains rr. + +A basic MSAN build can be configured with: + +cmake \ + -DWITH_MSAN=ON \ + -DCMAKE_{EXE,MODULE}_LINKER_FLAGS="-L${MSAN_LIBDIR} -Wl,-rpath=${MSAN_LIBDIR}" \ + -DWITH_INNODB_{BZIP2,LZ4,LZMA,LZO,SNAPPY}=OFF \ + -DUPDATE_SUBMODULES=OFF \ + -DPLUGIN_COLUMNSTORE=NO \ + -DWITH_UNIT_TESTS=OFF \ + -DWITH_ZLIB=bundled \ + -DWITH_SYSTEMD=no \ + -DWITH_DBUG_TRACE=OFF \ + /source + +A basic combined UBSAN/ASAN build can be configured with: + +cmake -DWITH_ASAN=ON -DWITH_ASAN_SCOPED=ON -DWITH_UBSAN=ON -DWITH_UNIT_TESTS=OFF /source + +Build with: + +cmake --build . + +Test with: + +mysql-test/mtr --parallel=auto + +There are UBSAN filters covering currently unfixed bugs within +the server that can be used to direct your development, or validate if a +observed failure is known. + +Perform the following to download/inspect them: + +curl https://raw.githubusercontent.com/mariadb-corporation/mariadb-qa/refs/heads/master/UBSAN.filter -o /build/UBSAN.filter + +After this, add suppressions to UBSAN_OPTIONS with + +export UBSAN_OPTIONS=$UBSAN_OPTIONS:suppressions=/build/UBSAN.filter + +To mark a function as unoptimized use the attribute: + + __attribute__((optnone)) + +rr is available if the container is started with --privileged. + +ref sanitizer flags documents: +* https://github.com/google/sanitizers/wiki/AddressSanitizerFlags +* https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html +* https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/installing-mariadb/compiling-mariadb-from-source/compile-and-using-mariadb-with-sanitizers-asan-ubsan-tsan-msan#buildbots-msan-container From ee09212b32a12dc2871bf44ca35bfb3a9223aedb Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 22 Aug 2025 13:47:42 +1000 Subject: [PATCH 2/9] msan image: clang-21/22 compat --- ci_build_images/msan.fragment.Dockerfile | 2 +- ci_build_images/msan.instrumentedlibs.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ci_build_images/msan.fragment.Dockerfile b/ci_build_images/msan.fragment.Dockerfile index 63fce8870..fe5b2639c 100644 --- a/ci_build_images/msan.fragment.Dockerfile +++ b/ci_build_images/msan.fragment.Dockerfile @@ -9,7 +9,7 @@ ARG CLANG_VERSION=20 # This CLANG_DEV_VERSION is a marker to make it possible to build a msan builder # from the nightly clang versions as they are in a differently name repositories. # This maps to the https://apt.llvm.org/ under "development" branch version. -ENV CLANG_DEV_VERSION=21 +ENV CLANG_DEV_VERSION=22 WORKDIR /msan-build diff --git a/ci_build_images/msan.instrumentedlibs.sh b/ci_build_images/msan.instrumentedlibs.sh index e6270eade..5eb8ea1ed 100755 --- a/ci_build_images/msan.instrumentedlibs.sh +++ b/ci_build_images/msan.instrumentedlibs.sh @@ -65,7 +65,8 @@ rm -rf -- * apt-get source libidn2 mv libidn2-*/* . mk-build-deps -it 'apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes' -./configure --enable-valgrind-tests=no +make -f debian/rules execute_before_dh_auto_configure +./configure --enable-valgrind-tests=no --enable-doc=no make -j "$(nproc)" cp -aL lib/.libs/libidn2.so* "$MSAN_LIBDIR" rm -rf -- * From 9f21433e4ccbe11ff363b3963c1841b4fd37507f Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 22 Aug 2025 14:08:58 +1000 Subject: [PATCH 3/9] msan images: build clang 21 and development 22 version --- .github/workflows/build-debian.msan-based.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/build-debian.msan-based.yml b/.github/workflows/build-debian.msan-based.yml index 799b44059..bb6395393 100644 --- a/.github/workflows/build-debian.msan-based.yml +++ b/.github/workflows/build-debian.msan-based.yml @@ -40,6 +40,18 @@ jobs: tag: debian12-msan-clang-20 clang_version: 20 nogalera: false + - image: debian:13 + platforms: linux/amd64 + branch: 11.4 + tag: debian13-msan-clang-21 + clang_version: 21 + nogalera: false + - image: debian:13 + platforms: linux/amd64 + branch: 11.8 + tag: debian13-msan-clang-22 + clang_version: 22 + nogalera: false uses: ./.github/workflows/bbw_build_container_template.yml with: From ba45fbcb763c47b212bedd968cec322ebbcfbacf Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 25 Aug 2025 13:36:17 +1000 Subject: [PATCH 4/9] msan: motd - disable liburing Until https://github.com/MariaDB/server/pull/4257 is merged up lets keep the motd slightly conservative. --- ci_build_images/msan.motd | 1 + 1 file changed, 1 insertion(+) diff --git a/ci_build_images/msan.motd b/ci_build_images/msan.motd index fede90252..c03f622ce 100644 --- a/ci_build_images/msan.motd +++ b/ci_build_images/msan.motd @@ -8,6 +8,7 @@ cmake \ -DWITH_MSAN=ON \ -DCMAKE_{EXE,MODULE}_LINKER_FLAGS="-L${MSAN_LIBDIR} -Wl,-rpath=${MSAN_LIBDIR}" \ -DWITH_INNODB_{BZIP2,LZ4,LZMA,LZO,SNAPPY}=OFF \ + -DCMAKE_DISABLE_FIND_PACKAGE_URING=1 \ -DUPDATE_SUBMODULES=OFF \ -DPLUGIN_COLUMNSTORE=NO \ -DWITH_UNIT_TESTS=OFF \ From 1ead32c016e010590ce1af6f8dc793df4e1088d2 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 4 Sep 2025 12:31:21 +1000 Subject: [PATCH 5/9] motd update --- ci_build_images/msan.motd | 49 ++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/ci_build_images/msan.motd b/ci_build_images/msan.motd index c03f622ce..87fdd3bfa 100644 --- a/ci_build_images/msan.motd +++ b/ci_build_images/msan.motd @@ -2,51 +2,58 @@ This is a container for ASAN, UBSAN and MSAN building. It can also be used as a basic build/test that contains rr. +rr is available if the container is started with --privileged. + +The following assumed that /source is a mounted volume of the +MariaDB source code. + A basic MSAN build can be configured with: -cmake \ - -DWITH_MSAN=ON \ - -DCMAKE_{EXE,MODULE}_LINKER_FLAGS="-L${MSAN_LIBDIR} -Wl,-rpath=${MSAN_LIBDIR}" \ - -DWITH_INNODB_{BZIP2,LZ4,LZMA,LZO,SNAPPY}=OFF \ - -DCMAKE_DISABLE_FIND_PACKAGE_URING=1 \ - -DUPDATE_SUBMODULES=OFF \ - -DPLUGIN_COLUMNSTORE=NO \ - -DWITH_UNIT_TESTS=OFF \ - -DWITH_ZLIB=bundled \ - -DWITH_SYSTEMD=no \ - -DWITH_DBUG_TRACE=OFF \ - /source + cmake \ + -DWITH_MSAN=ON \ + -DCMAKE_{EXE,MODULE}_LINKER_FLAGS="-L${MSAN_LIBDIR} -Wl,-rpath=${MSAN_LIBDIR}" \ + -DWITH_INNODB_{BZIP2,LZ4,LZMA,LZO,SNAPPY}=OFF \ + -DCMAKE_DISABLE_FIND_PACKAGE_URING=1 \ + -DUPDATE_SUBMODULES=OFF \ + -DPLUGIN_COLUMNSTORE=NO \ + -DWITH_UNIT_TESTS=OFF \ + -DWITH_ZLIB=bundled \ + -DWITH_SYSTEMD=no \ + -DWITH_DBUG_TRACE=OFF \ + /source A basic combined UBSAN/ASAN build can be configured with: -cmake -DWITH_ASAN=ON -DWITH_ASAN_SCOPED=ON -DWITH_UBSAN=ON -DWITH_UNIT_TESTS=OFF /source + cmake -DWITH_ASAN=ON -DWITH_ASAN_SCOPED=ON -DWITH_UBSAN=ON -DWITH_UNIT_TESTS=OFF -DUPDATE_SUBMODULES=OFF /source Build with: -cmake --build . + cmake --build . Test with: -mysql-test/mtr --parallel=auto + mysql-test/mtr --parallel=auto + +Add --rr to record a specific MTR test. To replay: + + rr replay mysql-test/var/log/mysqld.1.rr/mariadb-0 There are UBSAN filters covering currently unfixed bugs within -the server that can be used to direct your development, or validate if a -observed failure is known. +the server that can be used to direct your development, or validate +if a observed failure is known. Perform the following to download/inspect them: -curl https://raw.githubusercontent.com/mariadb-corporation/mariadb-qa/refs/heads/master/UBSAN.filter -o /build/UBSAN.filter + curl https://raw.githubusercontent.com/mariadb-corporation/mariadb-qa/refs/heads/master/UBSAN.filter -o /build/UBSAN.filter After this, add suppressions to UBSAN_OPTIONS with -export UBSAN_OPTIONS=$UBSAN_OPTIONS:suppressions=/build/UBSAN.filter + export UBSAN_OPTIONS=$UBSAN_OPTIONS:suppressions=/build/UBSAN.filter To mark a function as unoptimized use the attribute: __attribute__((optnone)) -rr is available if the container is started with --privileged. - ref sanitizer flags documents: * https://github.com/google/sanitizers/wiki/AddressSanitizerFlags * https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html From 24321b1e0bf39f3a47f598ec61c1675bba738a2a Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 26 Aug 2025 15:58:07 +1000 Subject: [PATCH 6/9] msan: build on ubuntu-24.04 --- .github/workflows/build-debian.msan-based.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-debian.msan-based.yml b/.github/workflows/build-debian.msan-based.yml index bb6395393..3de102d12 100644 --- a/.github/workflows/build-debian.msan-based.yml +++ b/.github/workflows/build-debian.msan-based.yml @@ -62,6 +62,7 @@ jobs: branch: ${{ matrix.branch }} clang_version: ${{ matrix.clang_version }} nogalera: ${{ matrix.nogalera }} + runner: 'ubuntu-24.04' files: '[ {"name": "msan.instrumentedlibs.sh", "source": "''$WORKDIR/msan.instrumentedlibs.sh''", "target": "''$GITHUB_WORKSPACE''"}, From 133e08b359865a3f70712c178df1d8ab76eda678 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 4 Sep 2025 16:25:28 +1000 Subject: [PATCH 7/9] msan motd: no compressions -dev lib packages + uring fixed --- ci_build_images/msan.motd | 2 -- 1 file changed, 2 deletions(-) diff --git a/ci_build_images/msan.motd b/ci_build_images/msan.motd index 87fdd3bfa..bad4f7667 100644 --- a/ci_build_images/msan.motd +++ b/ci_build_images/msan.motd @@ -12,8 +12,6 @@ A basic MSAN build can be configured with: cmake \ -DWITH_MSAN=ON \ -DCMAKE_{EXE,MODULE}_LINKER_FLAGS="-L${MSAN_LIBDIR} -Wl,-rpath=${MSAN_LIBDIR}" \ - -DWITH_INNODB_{BZIP2,LZ4,LZMA,LZO,SNAPPY}=OFF \ - -DCMAKE_DISABLE_FIND_PACKAGE_URING=1 \ -DUPDATE_SUBMODULES=OFF \ -DPLUGIN_COLUMNSTORE=NO \ -DWITH_UNIT_TESTS=OFF \ From 65a608ecfec79238257d17c33e34564afa2b2e80 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 12 Sep 2025 19:02:52 +1000 Subject: [PATCH 8/9] msan motd: no columnstore on ASAN/UBSAN either Out of tree build cannot build on read only source directory --- ci_build_images/msan.motd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ci_build_images/msan.motd b/ci_build_images/msan.motd index bad4f7667..0de73ac2a 100644 --- a/ci_build_images/msan.motd +++ b/ci_build_images/msan.motd @@ -22,7 +22,11 @@ A basic MSAN build can be configured with: A basic combined UBSAN/ASAN build can be configured with: - cmake -DWITH_ASAN=ON -DWITH_ASAN_SCOPED=ON -DWITH_UBSAN=ON -DWITH_UNIT_TESTS=OFF -DUPDATE_SUBMODULES=OFF /source + cmake -DWITH_ASAN=ON -DWITH_ASAN_SCOPED=ON -DWITH_UBSAN=ON \ + -DUPDATE_SUBMODULES=OFF \ + -DPLUGIN_COLUMNSTORE=NO \ + -DWITH_UNIT_TESTS=OFF \ + /source Build with: From 68901fe39b9124fab610228e6ede97e552c52dca Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 19 Sep 2025 09:51:30 +1000 Subject: [PATCH 9/9] MDBF-1125: MSAN instrument curl libraries This enables MSAN s3 tests to function correctly. --- ci_build_images/msan.instrumentedlibs.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ci_build_images/msan.instrumentedlibs.sh b/ci_build_images/msan.instrumentedlibs.sh index 5eb8ea1ed..b9b95f9b4 100755 --- a/ci_build_images/msan.instrumentedlibs.sh +++ b/ci_build_images/msan.instrumentedlibs.sh @@ -179,6 +179,13 @@ rm -rf -- * # shellcheck disable=SC2094 /usr/sbin/cracklib-packer /usr/share/dict/cracklib-small < /usr/share/dict/cracklib-small +# curl +apt-get source curl +mv curl*/* . +./configure --with-openssl --enable-ipv6 --disable-static --enable-websockets +make -j "$(nproc)" +mv ./lib/.libs/*.so* "$MSAN_LIBDIR" +rm -rf -- * # Now that we are built, clear out all the temporary build dependencies apt-get clean