Skip to content

Commit 42c6d2a

Browse files
committed
ci: sanitizers -- drop ASan from OpenSSL, LD_PRELOAD libasan at build
Real cause of "Failed to source env-setup": build-wolfprovider.sh runs its own internal `make test` after install. That triggers `openssl list -providers` which dlopens libwolfprov.so. With both the openssl binary and libwolfprov.so built with ASan, two ASan runtimes load and the dlopen fails silently (stderr swallowed by the build script's >/dev/null 2>&1). Fix: - Drop sanitizer flags from OpenSSL entirely. OpenSSL is third-party; we don't need to chase its upstream UBSan patterns. wolfprov is what this job is meant to instrument. - Export LD_PRELOAD=libasan before invoking build-wolfprovider.sh so the runtime is in the process when openssl dlopens the ASan-built libwolfprov.so during the build script's internal env-setup phase.
1 parent d8bf1b2 commit 42c6d2a

1 file changed

Lines changed: 10 additions & 28 deletions

File tree

.github/workflows/sanitizers.yml

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -78,29 +78,12 @@ jobs:
7878
7979
- name: Build wolfProvider with sanitizers
8080
env:
81-
# Dynamic libasan (no -static-libasan). With a static libasan
82-
# baked into the openssl binary, libwolfprov.so (which also
83-
# compiles in -fsanitize=address) ends up with a SECOND ASan
84-
# runtime when openssl dlopens it -- that aborts hard at
85-
# startup. Dynamic libasan everywhere puts a single runtime in
86-
# the process via the shared library.
87-
#
88-
# Test runs need LD_PRELOAD=libasan to keep ASan first in the
89-
# link order; that's set per-step below.
81+
# Only wolfprov + wolfssl get sanitizers. OpenSSL stays plain so
82+
# `openssl list -providers` works during the build script's
83+
# internal env-setup. LD_PRELOAD libasan keeps a single ASan
84+
# runtime in the process when openssl dlopens libwolfprov.so.
9085
SAN_FLAGS: "-fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize-recover=all -g"
91-
# OpenSSL gets -fsanitize-recover=undefined so benign upstream
92-
# UBSan trips don't abort `openssl list -providers` in env-setup.
93-
OPENSSL_CFLAGS: "-fsanitize=address,undefined -fno-omit-frame-pointer -fsanitize-recover=undefined -g"
94-
OPENSSL_CXXFLAGS: "-fsanitize=address,undefined -fno-omit-frame-pointer -fsanitize-recover=undefined -g"
95-
OPENSSL_LDFLAGS: "-fsanitize=address,undefined"
9686
run: |
97-
# The wolfSSL build script (scripts/utils-wolfssl.sh) treats
98-
# WOLFSSL_CONFIG_CFLAGS as a full override -- it only applies
99-
# the in-script default when the env var is unset/empty. So we
100-
# have to spell out the defaults explicitly here or wolfprov
101-
# ends up missing -DWC_RSA_NO_PADDING and the build fails with
102-
# "implicit declaration of wc_RsaDirect".
103-
#
10487
# Keep this in sync with the default in scripts/utils-wolfssl.sh.
10588
OPENSSL_INSTALL_DIR="${GITHUB_WORKSPACE}/openssl-install"
10689
export WOLFSSL_CONFIG_CFLAGS="\
@@ -115,21 +98,20 @@ jobs:
11598
-DRSA_MIN_SIZE=1024 \
11699
-DWOLFSSL_OLD_OID_SUM \
117100
${SAN_FLAGS}"
118-
119-
# wolfprov's default WOLFPROV_CONFIG_CFLAGS is empty and the
120-
# script appends its own -D defines after this override, so
121-
# only the sanitizer flags are needed here.
122101
export WOLFPROV_CONFIG_CFLAGS="${SAN_FLAGS}"
123102
103+
# Pre-load libasan so the build script's internal `make test`
104+
# (which runs `openssl list -providers` -> dlopen libwolfprov.so)
105+
# has the ASan runtime already mapped in. Without this, dlopen
106+
# fails with "ASan runtime not loaded".
107+
export LD_PRELOAD="$(gcc -print-file-name=libasan.so)"
108+
124109
OPENSSL_TAG=${{ needs.discover_versions.outputs.openssl_latest_ref }} \
125110
WOLFSSL_TAG=${{ matrix.wolfssl_ref }} \
126111
./scripts/build-wolfprovider.sh
127112
128113
- name: Run cmd-tests under sanitizers
129114
run: |
130-
# LD_PRELOAD libasan first so it wins symbol resolution against
131-
# dlopen'd libwolfprov.so. Without this, depending on link
132-
# order, ASan can complain about "interceptors not installed".
133115
export LD_PRELOAD="$(gcc -print-file-name=libasan.so)"
134116
source scripts/env-setup
135117
./scripts/cmd_test/do-cmd-tests.sh

0 commit comments

Comments
 (0)