|
123 | 123 | # Patch dd-java-agent.jar with the locally built ddprof contents so the |
124 | 124 | # agent's (relocated) profiler classes match the version under test. |
125 | 125 | PATCHED_AGENT="${WORK_DIR}/dd-java-agent-patched.jar" |
126 | | -DD_AGENT_JAR="${DD_AGENT_JAR}" DDPROF_JAR="${DDPROF_JAR}" OUTPUT_JAR="${PATCHED_AGENT}" \ |
127 | | - "${ROOT}/utils/patch-dd-java-agent.sh" |
128 | | -if [ ! -f "${PATCHED_AGENT}" ]; then |
| 126 | +if ! DD_AGENT_JAR="${DD_AGENT_JAR}" DDPROF_JAR="${DDPROF_JAR}" OUTPUT_JAR="${PATCHED_AGENT}" \ |
| 127 | + "${ROOT}/utils/patch-dd-java-agent.sh"; then |
129 | 128 | echo "FAIL:dd-java-agent patching failed" >&2 |
130 | 129 | exit 1 |
131 | 130 | fi |
| 131 | +if [ ! -f "${PATCHED_AGENT}" ]; then |
| 132 | + echo "FAIL:dd-java-agent patching reported success but output jar is missing" >&2 |
| 133 | + exit 1 |
| 134 | +fi |
132 | 135 |
|
133 | 136 | case $CONFIG in |
134 | 137 | profiler) |
@@ -163,6 +166,23 @@ case $ALLOCATOR in |
163 | 166 | # (mirrors the tcmalloc/jemalloc tuning below). |
164 | 167 | export MALLOC_ARENA_MAX=2 |
165 | 168 | export MALLOC_TRIM_THRESHOLD_=65536 |
| 169 | + # glibc >= 2.34 moved MALLOC_CHECK_ support out of the main libc; it is a |
| 170 | + # silent no-op unless libc_malloc_debug is preloaded (see glibc's "Heap |
| 171 | + # Consistency Checking" docs). Detect that case and preload the debug |
| 172 | + # library explicitly, rather than silently running with corruption |
| 173 | + # detection disabled. |
| 174 | + if command -v ldd >/dev/null 2>&1; then |
| 175 | + GLIBC_VERSION=$(ldd --version 2>/dev/null | head -1 | grep -oE '[0-9]+\.[0-9]+$') |
| 176 | + if [ -n "${GLIBC_VERSION}" ] && [ "$(printf '%s\n' "2.34" "${GLIBC_VERSION}" | sort -V | head -1)" = "2.34" ]; then |
| 177 | + MALLOC_DEBUG_LIB=$(find /usr/lib/ /usr/lib64/ /lib/ /lib64/ -name 'libc_malloc_debug.so*' 2>/dev/null | head -1) |
| 178 | + if [ -z "${MALLOC_DEBUG_LIB}" ]; then |
| 179 | + echo "FAIL:glibc ${GLIBC_VERSION} requires libc_malloc_debug to be preloaded for MALLOC_CHECK_ to take effect, but it could not be found" >&2 |
| 180 | + exit 1 |
| 181 | + fi |
| 182 | + export LD_PRELOAD="${MALLOC_DEBUG_LIB}${LD_PRELOAD:+:${LD_PRELOAD}}" |
| 183 | + echo "glibc ${GLIBC_VERSION} detected — preloading ${MALLOC_DEBUG_LIB} for MALLOC_CHECK_" |
| 184 | + fi |
| 185 | + fi |
166 | 186 | ;; |
167 | 187 | tcmalloc) |
168 | 188 | export LD_PRELOAD=$(find /usr/lib/ /usr/lib64/ /opt/homebrew/lib/ /usr/local/lib/ -name 'libtcmalloc_minimal.so.4' -o -name 'libtcmalloc.dylib' 2>/dev/null | head -1) |
|
0 commit comments