Skip to content

Commit d703c2f

Browse files
committed
Merge branch 'fix/memcheck-leaks' into feat/test-scheduler
2 parents 4a8f145 + b6c40d3 commit d703c2f

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

‎internal/cbm/result_spill.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,20 @@
2929
* image that is read back whole and never interpreted byte by byte (CI MSan
3030
* lane on #2202: offset 4087, then 6714, of a 6,952-byte block). Under MSan
3131
* the image is declared defined right before the write; every other build
32-
* compiles this to nothing. */
32+
* compiles this to nothing. Valgrind Memcheck flags the same padding at the
33+
* write(2), so when its client-request header is available the image is
34+
* declared defined to it too (a few no-op instructions outside Valgrind). */
3335
#include "foundation/sanitized.h" /* __has_feature exists everywhere, cppcheck included */
3436
#if __has_feature(memory_sanitizer)
3537
#include <sanitizer/msan_interface.h>
3638
#define SPILL_IMAGE_DEFINED(p, n) __msan_unpoison((p), (n))
39+
#elif !defined(_WIN32) && defined(__has_include)
40+
#if __has_include(<valgrind/memcheck.h>)
41+
#include <valgrind/memcheck.h>
42+
#define SPILL_IMAGE_DEFINED(p, n) ((void)VALGRIND_MAKE_MEM_DEFINED((p), (n)))
43+
#else
44+
#define SPILL_IMAGE_DEFINED(p, n) ((void)0)
45+
#endif
3746
#else
3847
#define SPILL_IMAGE_DEFINED(p, n) ((void)0)
3948
#endif

‎requirements-ci.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
# Keep this separate from pkg/pypi/requirements-publish.txt: these packages are
33
# CI analyzers, not runtime or registry-publishing dependencies.
44
scancode-toolkit==32.5.0
5+
# pluggy 1.7.0 rejects plugincode 32.0.0's pre_scan hookspec module ("did not
6+
# find any 'pre_scan' hooks"), which breaks `scancode` at import. Keep the
7+
# last working release until plugincode supports 1.7.
8+
pluggy==1.6.0

‎scripts/analyze-memory.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ fi
2222

2323
RESULTS_DIR="${CBM_MEMORY_RESULTS_DIR:-$ROOT/memlab-memory-analysis}"
2424
RUN_ID="$(date +%Y%m%d-%H%M%S)-$$"
25+
mkdir -p "$ROOT/build"
2526
ANALYSIS_BUILD="$(mktemp -d "$ROOT/build/memory-analysis.XXXXXX")"
2627
TEST_BIN="$ANALYSIS_BUILD/test-runner"
2728
RUN_RESULTS="$RESULTS_DIR/$RUN_ID"

‎tests/test_daemon_ipc.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <stdlib.h>
2626
#include <string.h>
2727

28+
extern const char *cbm_test_program_path;
29+
2830
#ifdef _WIN32
2931
#ifndef WIN32_LEAN_AND_MEAN
3032
#define WIN32_LEAN_AND_MEAN
@@ -3262,6 +3264,7 @@ TEST(daemon_ipc_posix_startup_lock_is_cross_process) {
32623264
int child_result = ipc_test_cross_process_lock_child(endpoint, commands[0], results[1]);
32633265
(void)close(commands[0]);
32643266
(void)close(results[1]);
3267+
cbm_daemon_ipc_endpoint_free(endpoint);
32653268
_exit(child_result);
32663269
}
32673270
if (child > 0) {
@@ -3352,6 +3355,7 @@ TEST(daemon_ipc_posix_lifetime_reservation_rejects_fork_inheritance) {
33523355
cbm_daemon_ipc_lifetime_reservation_release(inherited);
33533356
bool reported = ipc_test_fd_write_all(result_pipe[1], &child_result, sizeof(child_result));
33543357
(void)close(result_pipe[1]);
3358+
cbm_daemon_ipc_endpoint_free(endpoint);
33553359
_exit(reported && child_result == 1 ? 0 : 1);
33563360
}
33573361
if (child > 0) {
@@ -3447,6 +3451,7 @@ TEST(daemon_ipc_posix_child_participant_handoff_retains_legacy_bridge) {
34473451
ipc_test_fd_write_all(child_to_parent[1], &release_byte, sizeof(release_byte));
34483452
(void)close(parent_to_child[0]);
34493453
(void)close(child_to_parent[1]);
3454+
cbm_daemon_ipc_endpoint_free(endpoint);
34503455
_exit(join_byte == 1 && release_reported && release_byte == 1 ? 0 : 1);
34513456
}
34523457
if (child > 0) {
@@ -5581,6 +5586,14 @@ TEST(daemon_ipc_posix_single_uid_userns_real_smoke_issue1830) {
55815586
* unprivileged userns) -- while looking like a product regression.
55825587
* Re-exec so the decision is made by a process that STARTED here, which
55835588
* is also the only shape production ever takes. */
5589+
/* /proc/self/exe can name Valgrind itself here. Re-exec the runner
5590+
* path recorded from argv[0] so the probe starts fresh in the namespace.
5591+
* A relative argv[0] stops resolving once an earlier test changes the
5592+
* working directory, so fall back to /proc/self/exe. */
5593+
if (cbm_test_program_path) {
5594+
(void)execl(cbm_test_program_path, "test-runner", "--userns-secure-probe", probe,
5595+
(char *)NULL);
5596+
}
55845597
(void)execl("/proc/self/exe", "test-runner", "--userns-secure-probe", probe, (char *)NULL);
55855598
_exit(3); /* exec failed -- distinct from secure(0)/refused(1)/skip(2) */
55865599
}

0 commit comments

Comments
 (0)