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

@ -505,6 +505,9 @@ void kill_resreq_ctx(resreq_context_t* ctx)
if (ctx == NULL) {
return;
}
/* bug-1884: a primary's parse error lands here (xce_resreq.peg) */
FREEUP(ctx->errmsg);
}
int parse_resreq(xce_resreq_t* resreq, char* data, var resmgr, char** errmsg)

View file

@ -106,6 +106,8 @@ primary_resreq <- < (! ('{' / '}' ) .)* > {
xce_primary_resreq_t *primary = (xce_primary_resreq_t *)calloc(1, sizeof(*primary));
if (primary != NULL) {
auxil->primary = primary;
free(auxil->errmsg); /* bug-1884: an earlier primary's message */
auxil->errmsg = NULL;
parse_resreq_primary(primary, (char *)$0, auxil->resmgr, &(auxil->errmsg));
}
}