Skip to content

Commit d9fa2a3

Browse files
CDRIVER-4272: Add options and code to load the csfle dynamic library (#968)
* Incorporate changes for csfle in libmongocrypt * Document new extraOptions for auto-encryption * Add mongodl, download a csfle library for testing. Use csfle in test processes if possible * Fix: forked child processes must not used exit() nor allocating functions. This is discovered because the mongocryptd spawner will cause the atexit() code to run from the csfle library loaded in the process. * Do not append csfle search paths if we are explicit or bypassing auto-encryption Refer: [DRIVERS-2287] * Fix mongodl for rhel versions and ASCII stdout * Remove BSON_MEMCHECK. We're getting ODR trouble. * Skip failing CSE tests for now
1 parent 904db53 commit d9fa2a3

21 files changed

+924
-82
lines changed

.evergreen/config.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,6 @@ tasks:
10561056
shell: bash
10571057
script: |-
10581058
set -o errexit
1059-
export CFLAGS="-DBSON_MEMCHECK"
10601059
export DEBUG="ON"
10611060
export SASL="OFF"
10621061
export SSL="OPENSSL"
@@ -1111,7 +1110,7 @@ tasks:
11111110
script: |-
11121111
set -o errexit
11131112
export CC="clang-3.8"
1114-
export CFLAGS="-fsanitize=address -fno-omit-frame-pointer -DBSON_MEMCHECK"
1113+
export CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
11151114
export CHECK_LOG="ON"
11161115
export DEBUG="ON"
11171116
export EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF"
@@ -1155,7 +1154,7 @@ tasks:
11551154
script: |-
11561155
set -o errexit
11571156
export CC="clang-3.8"
1158-
export CFLAGS="-fsanitize=address -fno-omit-frame-pointer -DBSON_MEMCHECK"
1157+
export CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
11591158
export CHECK_LOG="ON"
11601159
export DEBUG="ON"
11611160
export EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF"
@@ -1178,7 +1177,7 @@ tasks:
11781177
script: |-
11791178
set -o errexit
11801179
export CC="clang-3.8"
1181-
export CFLAGS="-fsanitize=undefined -fno-omit-frame-pointer -DBSON_MEMCHECK"
1180+
export CFLAGS="-fsanitize=undefined -fno-omit-frame-pointer"
11821181
export CHECK_LOG="ON"
11831182
export DEBUG="ON"
11841183
export EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF"
@@ -1943,7 +1942,7 @@ tasks:
19431942
shell: bash
19441943
script: |-
19451944
set -o errexit
1946-
export CFLAGS="-fsanitize=address -fno-omit-frame-pointer -DBSON_MEMCHECK"
1945+
export CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
19471946
export CHECK_LOG="ON"
19481947
export DEBUG="ON"
19491948
export EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON -DENABLE_MONGOC=OFF -DENABLE_EXTRA_ALIGNMENT=OFF"
@@ -1953,7 +1952,7 @@ tasks:
19531952
CC='${CC}' MARCH='${MARCH}' sh .evergreen/compile.sh
19541953
rm CMakeCache.txt
19551954
set -o errexit
1956-
export CFLAGS="-fPIC -fsanitize=address -fno-omit-frame-pointer -DBSON_MEMCHECK"
1955+
export CFLAGS="-fPIC -fsanitize=address -fno-omit-frame-pointer"
19571956
export CHECK_LOG="ON"
19581957
export COMPILE_LIBMONGOCRYPT="ON"
19591958
export DEBUG="ON"
@@ -14282,7 +14281,7 @@ tasks:
1428214281
shell: bash
1428314282
script: |-
1428414283
set -o errexit
14285-
VALGRIND=ON DEBUG=ON CC='${CC}' MARCH='${MARCH}' SASL=AUTO SSL=OPENSSL CFLAGS='-DBSON_MEMCHECK' sh .evergreen/compile.sh
14284+
VALGRIND=ON DEBUG=ON CC='${CC}' MARCH='${MARCH}' SASL=AUTO SSL=OPENSSL sh .evergreen/compile.sh
1428614285
- func: run auth tests
1428714286
vars:
1428814287
valgrind: 'true'

.evergreen/run-tests.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,19 @@ if [ "$CLIENT_SIDE_ENCRYPTION" = "on" ]; then
110110
wait_for_kms_server 8002
111111
wait_for_kms_server 5698
112112
echo "Waiting for mock KMS servers to start... done."
113+
if ! test -d /cygdrive/c; then
114+
# We have trouble with this test on Windows. only set csflePath on other platforms
115+
export MONGOC_TEST_CSFLE_PATH="$(find . -wholename '*src/libmongoc/mongo_csfle_v1.*' -and -regex '.*\(.dll\|.dylib\|.so\)' | head -n1)"
116+
echo "Setting env csflePath: [$MONGOC_TEST_CSFLE_PATH]"
117+
fi
113118
fi
114119

115120
if [ "$LOADBALANCED" != "noloadbalanced" ]; then
116121
if [ -z "$SINGLE_MONGOS_LB_URI" -o -z "$MULTI_MONGOS_LB_URI" ]; then
117122
echo "SINGLE_MONGOS_LB_URI and MULTI_MONGOS_LB_URI environment variables required."
118123
exit 1
119124
fi
120-
125+
121126
export MONGOC_TEST_LOADBALANCED=ON
122127

123128
TEST_ARGS="$TEST_ARGS -l /unified/*"

.evergreen/skip-tests.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,5 @@
8686
/sessions/unified/snapshot-sessions/"countDocuments operation with snapshot" # (CDRIVER-4355) error: checking expectResult: { "$numberInt" : "2" }
8787
/load_balancers/non-lb-connection-establishment/"operations against non-load balanced clusters fail if URI contains loadBalanced=true" # (CDRIVER-4356) error: expected error to contain "Driver attempted to initialize in load balancing mode, but the server does not support this mode", but got: "BSON field 'hello.loadBalanced' is an unknown field."
8888

89+
/client_side_encryption/explain # Failure with diverging behavior between csfle and mongocryptd
90+
/client_side_encryption/bypass_spawning_mongocryptd/mongocryptdBypassSpawn # Fails if csfle is visible

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ CMakeFiles
1616
CPackConfig.cmake
1717
CPackSourceConfig.cmake
1818
CTestTestfile.cmake
19+
_build/
1920
dist_manifest.txt
2021
Makefile
2122
test-results.json

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ set (CMAKE_MODULE_PATH
7878

7979
include (InstallRequiredSystemLibraries)
8080
include (GNUInstallDirs)
81+
include (CMakeDependentOption)
8182

8283
include(MongoC-Warnings)
8384

build/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set_local_dist (build_DIST_local
66
maintainer-flags.txt
77
generate-uninstall.cmd
88
generate-uninstall.sh
9+
mongodl.py
910
)
1011

1112
set (build_DIST

build/evergreen_config_lib/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@
494494
echo $(cat dir.txt)
495495
496496
export RUN_MONGOHOUSE_TESTS=true
497-
./src/libmongoc/test-libmongoc --no-fork -l /mongohouse/* -d
497+
./src/libmongoc/test-libmongoc --no-fork -l /mongohouse/* -d --skip-tests .evergreen/skip-tests.txt
498498
unset RUN_MONGOHOUSE_TESTS
499499
500500
'''),

build/evergreen_config_lib/tasks.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def __init__(self, *args, **kwargs):
116116
class CompileWithClientSideEncryptionAsan(CompileTask):
117117
def __init__(self, *args, **kwargs):
118118
compile_with_cse = CompileTask(*args,
119-
CFLAGS="-fPIC -fsanitize=address -fno-omit-frame-pointer -DBSON_MEMCHECK",
119+
CFLAGS="-fPIC -fsanitize=address -fno-omit-frame-pointer",
120120
COMPILE_LIBMONGOCRYPT="ON",
121121
CHECK_LOG="ON",
122122
EXTRA_CONFIGURE_FLAGS="-DENABLE_CLIENT_SIDE_ENCRYPTION=ON -DENABLE_EXTRA_ALIGNMENT=OFF",
@@ -127,7 +127,7 @@ def __init__(self, *args, **kwargs):
127127

128128
# Skip running mock server tests, because those were already run in the non-CSE build.
129129
super(CompileWithClientSideEncryptionAsan, self).__init__(*args,
130-
CFLAGS="-fsanitize=address -fno-omit-frame-pointer -DBSON_MEMCHECK",
130+
CFLAGS="-fsanitize=address -fno-omit-frame-pointer",
131131
extra_script=extra_script,
132132
CHECK_LOG="ON",
133133
EXTRA_CONFIGURE_FLAGS="-DENABLE_PIC=ON -DENABLE_MONGOC=OFF -DENABLE_EXTRA_ALIGNMENT=OFF",
@@ -198,8 +198,7 @@ def __init__(self, task_name, suffix_commands, orchestration=True, **kwargs):
198198
tags=['debug-compile', 'valgrind'],
199199
SASL='OFF',
200200
SSL='OPENSSL',
201-
VALGRIND='ON',
202-
CFLAGS='-DBSON_MEMCHECK'),
201+
VALGRIND='ON'),
203202
SpecialTask('debug-compile-coverage',
204203
tags=['debug-compile', 'coverage'],
205204
COVERAGE='ON',
@@ -211,8 +210,7 @@ def __init__(self, task_name, suffix_commands, orchestration=True, **kwargs):
211210
tags=['debug-compile', 'asan-clang'],
212211
compression='zlib',
213212
CC='clang-3.8',
214-
CFLAGS='-fsanitize=address -fno-omit-frame-pointer'
215-
' -DBSON_MEMCHECK',
213+
CFLAGS='-fsanitize=address -fno-omit-frame-pointer',
216214
CHECK_LOG='ON',
217215
EXTRA_CONFIGURE_FLAGS='-DENABLE_EXTRA_ALIGNMENT=OFF',
218216
PATH='/usr/lib/llvm-3.8/bin:$PATH'),
@@ -227,17 +225,15 @@ def __init__(self, task_name, suffix_commands, orchestration=True, **kwargs):
227225
tags=['debug-compile', 'asan-clang'],
228226
compression='zlib',
229227
CC='clang-3.8',
230-
CFLAGS='-fsanitize=address -fno-omit-frame-pointer'
231-
' -DBSON_MEMCHECK',
228+
CFLAGS='-fsanitize=address -fno-omit-frame-pointer',
232229
CHECK_LOG='ON',
233230
EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF",
234231
PATH='/usr/lib/llvm-3.8/bin:$PATH',
235232
SSL='OPENSSL'),
236233
SpecialTask('debug-compile-ubsan',
237234
compression='zlib',
238235
CC='clang-3.8',
239-
CFLAGS='-fsanitize=undefined -fno-omit-frame-pointer'
240-
' -DBSON_MEMCHECK',
236+
CFLAGS='-fsanitize=undefined -fno-omit-frame-pointer',
241237
CHECK_LOG='ON',
242238
EXTRA_CONFIGURE_FLAGS="-DENABLE_EXTRA_ALIGNMENT=OFF",
243239
PATH='/usr/lib/llvm-3.8/bin:$PATH'),
@@ -843,7 +839,7 @@ def __init__(self, *args, **kwargs):
843839
commands=[
844840
shell_mongoc("""
845841
VALGRIND=ON DEBUG=ON CC='${CC}' MARCH='${MARCH}' SASL=AUTO \
846-
SSL=OPENSSL CFLAGS='-DBSON_MEMCHECK' sh .evergreen/compile.sh
842+
SSL=OPENSSL sh .evergreen/compile.sh
847843
"""),
848844
func('run auth tests', valgrind='true')]),
849845
PostCompileTask(

build/maintainer-flags.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
-Wall
2-
-Wdeclaration-after-statement
32
-Wempty-body
43
-Wformat
54
-Wformat-nonliteral
65
-Wformat-security
76
-Winit-self
8-
-Winline
97
-Wmissing-include-dirs
108
-Wno-strict-aliasing
119
-Wno-uninitialized
@@ -16,4 +14,4 @@
1614
-Wundef
1715
-Wuninitialized
1816
-Wexpansion-to-defined
19-
-pedantic
17+
-pedantic

0 commit comments

Comments
 (0)