fix(scheduler): a batch replay exits 0 under LeakSanitizer (bug-1884, part 6)

- kill_sched_resval() (every resource-value array's item killer) frees
  the value, not only a string's buffer: each replaced or torn-down value
  leaked its struct, including every WORKERS_PUSH value update.
- put_resvals() shares the value it creates with later entries for the
  same index in one call; it created a second one that replaced (and now
  freed) the first while still writing through it.
- JOB_UPDATE and the duplicate-JOBS_PUSH path kill_resreq() the old parsed
  resreq, and free the rejected job's schedobj (xce_core_free_schedobj(),
  exported from core.c), instead of freeing only the containers.
- The previous attempt's (or ALTER alternative's) pend reason is freed when
  a new one replaces it.
- kill_resreq_ctx() frees the parser context's error message, and the
  primary-resreq PEG action frees an earlier primary's message first.
- write_snapshot_entry() frees the snapshot it builds (config and resource
  objects detached, they are the core's); the save side strdup()s its
  strings so the generated free_SnapshotData() applies.

Test: test_cli_batch_replay_exits_clean_under_leak_detection
(test_sim_discrete_clock.c) runs the real binary on a two-session fixture
with detect_leaks=1 and requires exit 0: RED before (exit 1), GREEN now.
All nine HA-soak recordings replay with exit 0 and no LeakSanitizer report.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-09-29 09:44:43 +00:00
parent f6cab0ab87
commit 90b99d91e9
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
12 changed files with 107 additions and 14 deletions

View file

@ -450,6 +450,12 @@ extern void xce_core_build_schedobj(xce_sched_obj_t*, const char* user,
const char* queue, const char* project,
xce_resreq_t*);
/* xce_core_free_schedobj - bug-1884: frees a schedobj built by
* xce_core_build_schedobj() (names, limit lists, per-primary wrappers and
* their pend reasons, last allocation and reason). Its resreqs belong to
* the job and are not freed. NULL-safe. */
extern void xce_core_free_schedobj(xce_sched_obj_t* obj);
/*
* sched_check_host_satisfy()/sched_check_shared_satisfy() - relocated here
* from scheduler.h (scheduler-driver-equivalence fix, bug-1836), following