Skip to content

Commit b6df2bb

Browse files
committed
Log MALLOC_PERTURB_ so glibc corruption aborts are reproducible
The value is random per run and was never surfaced, so a run that aborts on heap corruption couldn't be replayed with the same perturb byte.
1 parent 40bb433 commit b6df2bb

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

build-logic/conventions/src/main/kotlin/com/datadoghq/profiler/ProfilerTestPlugin.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,12 @@ class ProfilerTestPlugin : Plugin<Project> {
214214
!PlatformUtils.isMusl() &&
215215
!testEnv.containsKey("LD_PRELOAD")
216216
) {
217+
val perturbByte = (1..255).random()
217218
put("MALLOC_CHECK_", "3")
218-
put("MALLOC_PERTURB_", (1..255).random().toString())
219+
put("MALLOC_PERTURB_", perturbByte.toString())
220+
// Logged so a glibc-detected corruption abort can be reproduced with the
221+
// same perturb byte (the value is otherwise random per run).
222+
project.logger.lifecycle("[$configName] MALLOC_PERTURB_=$perturbByte")
219223
}
220224
putAll(testEnv)
221225
put("DDPROF_TEST_DISABLE_RATE_LIMIT", "1")

utils/run-chaos-harness.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ case $ALLOCATOR in
160160
# malloc, not the LD_PRELOAD-replaced allocators below.
161161
export MALLOC_CHECK_=3
162162
export MALLOC_PERTURB_=$((RANDOM % 255 + 1))
163+
# Logged so a glibc-detected corruption abort can be reproduced with the
164+
# same perturb byte (the value is otherwise random per run).
165+
echo "MALLOC_PERTURB_=${MALLOC_PERTURB_}"
163166
# thread-churn/dump-storm/vthread-context-cascade cycle many short-lived
164167
# threads; glibc's per-thread arenas are slow to trim back to the OS,
165168
# which was inflating container RSS past the OOM limit on aarch64

0 commit comments

Comments
 (0)