Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/workflows/build-debian.msan-based.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -38,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:
Expand All @@ -48,8 +62,10 @@ 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''"}
{"name": "msan.instrumentedlibs.sh", "source": "''$WORKDIR/msan.instrumentedlibs.sh''", "target": "''$GITHUB_WORKSPACE''"},
{"name": "msan.motd", "source": "''$WORKDIR/msan.motd''", "target": "''$GITHUB_WORKSPACE''"}
]'
secrets: inherit
49 changes: 4 additions & 45 deletions ci_build_images/msan.fragment.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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\
Comment thread
grooverdan marked this conversation as resolved.
-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
Expand Down
10 changes: 9 additions & 1 deletion ci_build_images/msan.instrumentedlibs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 -- *
Expand Down Expand Up @@ -178,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
Expand Down
62 changes: 62 additions & 0 deletions ci_build_images/msan.motd
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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}" \
-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 \
-DUPDATE_SUBMODULES=OFF \
-DPLUGIN_COLUMNSTORE=NO \
-DWITH_UNIT_TESTS=OFF \
/source

Build with:

cmake --build .

Test with:

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.

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))

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