Skip to content

Commit 2d94aeb

Browse files
author
Han Wang
committed
fix(ci): don't preload LSAN into gen script Python processes
The gen_*.py scripts import torch, which has internal pybind/JIT allocations that LSAN reports as leaks. These are not our leaks. Previously, LD_PRELOAD=liblsan.so was set for the gen scripts to handle dlopen of the sanitizer-built custom op .so, but this causes LSAN to track all Python/torch allocations and fail on exit. Fix: run gen scripts without LD_PRELOAD. The gen scripts don't need LSAN — only the C++ test binary (ctest) does, and ctest already inherits LSAN via the -fsanitize=leak compile flag. Also revert the DPA2 cpu_lmp_nlist test (needs further investigation).
1 parent 1bb7862 commit 2d94aeb

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

source/api_cc/tests/test_deeppot_dpa2_pt.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,6 @@ TYPED_TEST(TestInferDeepPotDpa2PtNoPbc, cpu_build_nlist) {
273273
}
274274
}
275275

276-
// TODO: This test uses a flat nlist with nloc==nall (no ghost atoms),
277-
// so it does not exercise the mapping/ghost-atom code path that a PBC
278-
// simulation with _build_nlist would test. Adding a proper PBC+ghost
279-
// lmp_nlist test requires generating reference values with ghost atoms,
280-
// which needs non-trivial test infrastructure changes.
281276
TYPED_TEST(TestInferDeepPotDpa2PtNoPbc, cpu_lmp_nlist) {
282277
using VALUETYPE = TypeParam;
283278
std::vector<VALUETYPE>& coord = this->coord;

source/install/test_cc_local.sh

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,15 @@ cmake --build . -j${NPROC}
3535
cmake --install .
3636
# Generate PT/PT2 model files for C++ tests.
3737
# Must run after cmake --build so that libdeepmd_op_pt.so (custom ops) is available.
38-
# When the build uses -fsanitize=leak, the resulting .so requires the LSAN runtime;
39-
# Python's dlopen would fail unless we preload it.
38+
# Run WITHOUT LSAN preload — LSAN is only needed for the C++ test binary.
39+
# Preloading LSAN into Python causes false leak reports from torch/paddle
40+
# internal allocations (pybind/JIT init).
4041
INFER_SCRIPT_PATH=${SCRIPT_PATH}/../tests/infer
41-
_GEN_ENV=""
42-
if echo "${CXXFLAGS:-}" | grep -q fsanitize=leak; then
43-
_LSAN_LIB=$(gcc -print-file-name=liblsan.so 2>/dev/null || true)
44-
if [ -n "${_LSAN_LIB}" ] && [ -f "${_LSAN_LIB}" ]; then
45-
_GEN_ENV="LD_PRELOAD=${_LSAN_LIB}"
46-
fi
47-
fi
48-
env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_sea.py
49-
env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_dpa1.py
50-
env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_dpa2.py
51-
env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_dpa3.py
52-
env ${_GEN_ENV} python ${INFER_SCRIPT_PATH}/gen_fparam_aparam.py
42+
python ${INFER_SCRIPT_PATH}/gen_sea.py
43+
python ${INFER_SCRIPT_PATH}/gen_dpa1.py
44+
python ${INFER_SCRIPT_PATH}/gen_dpa2.py
45+
python ${INFER_SCRIPT_PATH}/gen_dpa3.py
46+
python ${INFER_SCRIPT_PATH}/gen_fparam_aparam.py
5347
if [ "${ENABLE_PADDLE:-TRUE}" == "TRUE" ]; then
5448
PADDLE_INFERENCE_DIR=${BUILD_TMP_DIR}/paddle_inference_install_dir
5549
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PADDLE_INFERENCE_DIR}/third_party/install/onednn/lib:${PADDLE_INFERENCE_DIR}/third_party/install/mklml/lib

0 commit comments

Comments
 (0)