-
Notifications
You must be signed in to change notification settings - Fork 9
PG-1465 Add ASAN and UBSAN sanitizers #285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: TDE_REL_17_STABLE
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Sanitizers | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- TDE_REL_17_STABLE | ||
|
||
env: | ||
CC: clang | ||
LD: clang | ||
UBSAN_OPTIONS: log_path=${{ github.workspace }}/sanitize.log print_suppressions=0 print_stacktrace=1 print_summary=1 halt_on_error=1 | ||
ASAN_OPTIONS: log_path=${{ github.workspace }}/sanitize.log print_suppressions=0 abort_on_error=1 | ||
LSAN_OPTIONS: log_path=${{ github.workspace }}/sanitize.log print_suppressions=0 suppressions=${{ github.workspace }}/ci_scripts/suppressions/lsan.supp | ||
ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-14 | ||
EXTRA_REGRESS_OPTS: "--temp-config=${{ github.workspace }}/test_postgresql.conf" | ||
PGCTLTIMEOUT: 120 | ||
|
||
jobs: | ||
run: | ||
name: Run | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install dependencies | ||
run: ci_scripts/ubuntu-deps.sh | ||
|
||
- name: Build postgres | ||
run: ci_scripts/make-build.sh sanitize | ||
|
||
- name: Setup kmip and vault | ||
run: ci_scripts/setup-keyring-servers.sh | ||
|
||
- name: Configure test postgres | ||
run: echo 'max_stack_depth=8MB' > test_postgresql.conf | ||
|
||
- name: Run tests pg_tde tests | ||
run: ci_scripts/make-test.sh tde | ||
|
||
- name: Run PG regression tests | ||
run: ci_scripts/make-test.sh server | ||
|
||
- name: Print sanitize logs | ||
if: ${{ !cancelled() }} | ||
run: cat sanitize.log.* | ||
|
||
- name: Report on test fail | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ failure() }} | ||
with: | ||
name: sanitizers-testlog | ||
path: | | ||
build/testrun | ||
contrib/**/log | ||
contrib/**/regression.diffs | ||
contrib/**/regression.out | ||
contrib/**/results | ||
contrib/**/tmp_check | ||
contrib/**/t/results | ||
src/test/**/log | ||
src/test/**/regression.diffs | ||
src/test/**/regression.out | ||
src/test/**/results | ||
src/test/**/tmp_check | ||
sanitize.log.* | ||
retention-days: 3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
TDE_ONLY=0 | ||
|
||
for arg in "$@" | ||
do | ||
case "$arg" in | ||
--tde-only) | ||
TDE_ONLY=1 | ||
shift;; | ||
esac | ||
done | ||
|
||
SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" | ||
source "$SCRIPT_DIR/env.sh" | ||
|
||
if [ "$TDE_ONLY" -eq 1 ]; | ||
then | ||
cd "$SCRIPT_DIR/../contrib/pg_tde" | ||
make -s check | ||
else | ||
cd "$SCRIPT_DIR/.." | ||
make -s check-world | ||
fi | ||
|
||
case "$1" in | ||
server) | ||
echo "Run server regression tests" | ||
cd "$SCRIPT_DIR/.." | ||
make -s check | ||
;; | ||
|
||
tde) | ||
echo "Run tde tests" | ||
cd "$SCRIPT_DIR/../contrib/pg_tde" | ||
make -s check | ||
;; | ||
|
||
all) | ||
echo "Run all tests" | ||
cd "$SCRIPT_DIR/.." | ||
make -s check-world | ||
;; | ||
|
||
*) | ||
echo "Unknown test suite: $1" | ||
echo "Please use one of the following: server, tde, all" | ||
exit 1 | ||
;; | ||
esac |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,31 @@ source "$SCRIPT_DIR/env.sh" | |
|
||
cd "$SCRIPT_DIR/.." | ||
|
||
meson setup build --prefix "$INSTALL_DIR" --buildtype="$1" -Dcassert=true -Dtap_tests=enabled $ENABLE_COVERAGE | ||
BUILD_TYPE= | ||
|
||
case "$1" in | ||
debug) | ||
echo "Building with debug option" | ||
BUILD_TYPE=$1 | ||
;; | ||
|
||
debugoptimized) | ||
echo "Building with debugoptimized option" | ||
BUILD_TYPE=$1 | ||
;; | ||
|
||
sanitize) | ||
echo "Building with sanitize option" | ||
export CFLAGS="-fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -fno-inline-functions" | ||
BUILD_TYPE=debug | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the best practices about optimization and sanitizers? Our production build will be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't see information that |
||
;; | ||
|
||
*) | ||
echo "Unknown build type: $1" | ||
echo "Please use one of the following: debug, debugoptimized, sanitize" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
meson setup build --prefix "$INSTALL_DIR" --buildtype="$BUILD_TYPE" -Dcassert=true -Dtap_tests=enabled $ENABLE_COVERAGE | ||
cd build && ninja && ninja install |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,32 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
TDE_ONLY=0 | ||
|
||
for arg in "$@" | ||
do | ||
case "$arg" in | ||
--tde-only) | ||
TDE_ONLY=1 | ||
shift;; | ||
esac | ||
done | ||
|
||
SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" | ||
source "$SCRIPT_DIR/env.sh" | ||
|
||
cd "$SCRIPT_DIR/../build" | ||
|
||
if [ "$TDE_ONLY" -eq 1 ]; | ||
then | ||
meson test --suite setup --suite pg_tde | ||
else | ||
meson test | ||
fi | ||
|
||
case "$1" in | ||
server) | ||
echo "Run server regression tests" | ||
meson test --suite setup --suite regress | ||
;; | ||
|
||
tde) | ||
echo "Run tde tests" | ||
meson test --suite setup --suite pg_tde | ||
;; | ||
|
||
all) | ||
echo "Run all tests" | ||
meson test | ||
;; | ||
|
||
*) | ||
echo "Unknown test suite: $1" | ||
echo "Please use one of the following: server, tde, all" | ||
exit 1 | ||
;; | ||
esac |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
leak:save_ps_display_args | ||
leak:initdb.c | ||
leak:fe_memutils.c | ||
leak:fe-exec.c | ||
leak:fe-connect.c | ||
leak:pqexpbuffer.c | ||
leak:strdup | ||
leak:preproc.y | ||
leak:pgtypeslib/common.c | ||
leak:ecpglib/memory.c | ||
leak:kmip.c | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we create a ticket/tickets about this? Some of these supressions definitely seem like issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of them are not real issues, but "design features" or just allocation functions. I used timescale as a reference and they mute the same things: https://github.com/timescale/timescaledb/blob/main/scripts/suppressions/suppr_leak.txt But I'm agree that this list should be reviewed. Probably some mutes scope can be reduced. Here is the ticket: https://perconadev.atlassian.net/browse/PG-1588 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and strdup also seems to be a possible issue, or at least it can hide possible issues, as it suppresses any leaked strings created by strdup - even if it's a leak in postgres itself, we should look at that. |
||
|
||
#pg_dump | ||
leak:getSchemaData | ||
leak:dumpDumpableObject |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
|
||
PGTDE::append_to_result_file("-- kill -9"); | ||
$node->kill9(); | ||
sleep(3); # sanitizers slow down the kill, let server die in peace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I am missing something but how can There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the thread where exact same problem discussed: https://www.postgresql.org/message-id/flat/1709793.1644523137%40sss.pgh.pa.us#c4caef6ad812ecaceeb5b711b02ee8f4 So as I understood |
||
|
||
PGTDE::append_to_result_file("-- server start"); | ||
$node->start; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why you disable inlining? LLVM's documentation says nothing about that as far as I can see.
https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#stack-traces-and-report-symbolization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://clang.llvm.org/docs/AddressSanitizer.html#usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for ASAN. BTW it looks like it's worth to add
-fno-optimize-sibling-calls
as well.