diff --git a/Makefile b/Makefile index 5adc5370f0cd..5d41289029b8 100644 --- a/Makefile +++ b/Makefile @@ -618,7 +618,13 @@ $(JEMALLOC_DIR)/Makefile: $(C_DEPS_DIR)/jemalloc-rebuild $(JEMALLOC_SRC_DIR)/con mkdir -p $(JEMALLOC_DIR) @# NOTE: If you change the configure flags below, bump the version in @# $(C_DEPS_DIR)/jemalloc-rebuild. See above for rationale. - cd $(JEMALLOC_DIR) && $(JEMALLOC_SRC_DIR)/configure $(xconfigure-flags) --enable-prof + @# NOTE: we disable MADV_FREE; see https://github.com/cockroachdb/cockroach/issues/83790 + export je_cv_madv_free="no" && cd $(JEMALLOC_DIR) && $(JEMALLOC_SRC_DIR)/configure $(xconfigure-flags) --enable-prof + JEMALLOC_MADV_FREE_ENABLED=$$(grep -E "^je_cv_madv_free=no$$" $(JEMALLOC_DIR)/config.log | awk -F'=' '{print $$2}'); \ + if [[ "$$JEMALLOC_MADV_FREE_ENABLED" != "no" ]]; then \ + echo "NOTE: using MADV_FREE with jemalloc can lead to surprising results; see https://github.com/cockroachdb/cockroach/issues/83790"; \ + exit 1; \ + fi $(KRB5_SRC_DIR)/src/configure.in: | bin/.submodules-initialized diff --git a/c-deps/BUILD.bazel b/c-deps/BUILD.bazel index e23ff646f33d..531b3f77b017 100644 --- a/c-deps/BUILD.bazel +++ b/c-deps/BUILD.bazel @@ -41,8 +41,14 @@ configure_make( "//conditions:default": [], }), env = select({ - "//build/toolchains:dev": {"AR": ""}, - "//conditions:default": {}, + "//build/toolchains:dev": { + "AR": "", + # NOTE: we disable MADV_FREE; see https://github.com/cockroachdb/cockroach/issues/83790 + "je_cv_madv_free": "no", + }, + "//conditions:default": { + "je_cv_madv_free": "no", + }, }), lib_source = "@jemalloc//:all", out_static_libs = select({ diff --git a/c-deps/buildcdeps.sh b/c-deps/buildcdeps.sh index f76b642613f6..19c82ffa718e 100755 --- a/c-deps/buildcdeps.sh +++ b/c-deps/buildcdeps.sh @@ -19,6 +19,14 @@ for CONFIG in $CONFIGS; do bazel build --config ci --config cross$CONFIG --//build/toolchains:prebuild_cdeps_flag $(echo "$TARGETS" | python3 -c 'import sys; input = sys.stdin.read().strip(); print(" ".join("//c-deps:{}_foreign".format(w) for w in input.split(" ")))') BAZEL_BIN=$(bazel info bazel-bin --config ci --config cross$CONFIG) for TARGET in $TARGETS; do + # verify jemalloc was configured without madv_free + if [[ $TARGET == libjemalloc ]]; then + JEMALLOC_MADV_FREE_ENABLED=$((grep -E "^je_cv_madv_free=no$" $BAZEL_BIN/c-deps/${TARGET}_foreign_foreign_cc/Configure.log | awk -F"=" '{print $2}') || true) + if [[ "$JEMALLOC_MADV_FREE_ENABLED" != "no" ]]; then + echo "NOTE: using MADV_FREE with jemalloc can lead to surprising results; see https://github.com/cockroachdb/cockroach/issues/83790" + exit 1 + fi + fi bundle $CONFIG $BAZEL_BIN/c-deps/${TARGET}_foreign done done diff --git a/c-deps/jemalloc-rebuild b/c-deps/jemalloc-rebuild index 1a511033efa6..5a5421738c3f 100644 --- a/c-deps/jemalloc-rebuild +++ b/c-deps/jemalloc-rebuild @@ -1,4 +1,4 @@ Bump the version below when changing jemalloc configure flags. Search for "BUILD ARTIFACT CACHING" in build/common.mk for rationale. -5 +6