61 lines
3.7 KiB
Markdown
61 lines
3.7 KiB
Markdown
---
|
|
id: "bug-1885"
|
|
status: "fixed"
|
|
status_updated: "2026-09-29"
|
|
status_note: ""
|
|
component: "scheduler"
|
|
severity: "leak"
|
|
timestamp: "2026-09-29T09:48:44Z"
|
|
last_seen: "2026-09-29T09:48:44Z"
|
|
occurrences: 1
|
|
files: ["src/scheduler/src/driver.c", "src/scheduler/src/decision.c"]
|
|
tags: ["scheduler", "leak", "decision"]
|
|
related: ["bug-1884"]
|
|
fix_commits: ["d21b3d8f"]
|
|
---
|
|
|
|
# bug-1885: scheduler normal mode never frees decision structs: 64 bytes leaked per published decision
|
|
|
|
## Description
|
|
**Observed:** (code reading) the normal-mode round loop in
|
|
`xce_sched_driver_run_normal_mode_round()` (src/scheduler/src/driver.c)
|
|
drains each `xce_decision_t*` from `core->decisions`, records it and passes
|
|
it to `on_decision`, but never frees the struct `make_*_decision()`
|
|
(decision.c) calloc()s:
|
|
```
|
|
cbuf_get(&(sched->core.decisions), &decision);
|
|
... sched->core.on_decision(sched->core.driver_ctx, decision);
|
|
/* decision never freed */
|
|
```
|
|
|
|
**Expected:** the round loop frees the decision struct (not its alloc/pend reason, which the job owns) once published.
|
|
**Impact:** leak of 64 bytes per dispatch/pend decision for the life of a normal-mode scheduler. Simulation mode was fixed in bug-1884 (ebfe4794). Three tests (test_core_full_cycle.c, test_core_session.c, test_snapshot_save_load.c) keep decision pointers from their callback, so the fix changes the callback contract ("valid only during the call") and those tests.
|
|
**Found by:** review (while fixing bug-1884, 2026-09-29)
|
|
|
|
## Environment
|
|
- OS: no /etc/os-release; Docker container; NixOS kernel; kernel Linux 6.18.33 x86_64
|
|
- libc: glibc 2.42-47 (interpreter /nix/store/wb6rhpznjfczwlwx23zmdrrw74bayxw4-glibc-2.42-47/lib/ld-linux-x86-64.so.2)
|
|
- Toolchain: gcc (GCC) 15.2.0, meson 1.9.1
|
|
- Build: asan (src/xce.build.discrete)
|
|
- Code: scheduler-framework @ 90b99d91-dirty
|
|
- Deployment: n/a (found by code reading while fixing bug-1884; not observed on a deployment)
|
|
|
|
## Reproduction
|
|
1. Read `src/scheduler/src/driver.c` round loop (the `cbuf_get(&(sched->core.decisions), ...)` loop) and `src/scheduler/src/decision.c` `make_dispatch_decision()`/`make_pend_decision()`.
|
|
2. A live check: run a normal-mode scheduler under ASAN with detect_leaks=1 through a few rounds and stop it cleanly; expect `make_*_decision` direct leaks.
|
|
- Frequency: deterministic by code reading (one struct per decision)
|
|
- Evidence: not kept; code reading
|
|
|
|
## Root cause
|
|
`xce_sched_driver_run_normal_mode_round()` (driver.c) drains each decision from `core->decisions`, records it and passes it to `on_decision`, and never frees the struct `make_*_decision()` (decision.c) allocates.
|
|
|
|
## Fix
|
|
The round frees the decision struct after the callback returns (d21b3d8f). Its allocation/pend reason belong to the job; the publish callback passes those pointers on and the recorder copies, so nothing keeps the struct. Tests with their own drain loops (test_core_full_cycle.c, test_core_session.c, test_snapshot_save_load.c) are unaffected.
|
|
|
|
## Verification
|
|
- Test: test_round_frees_decision_after_callback in src/scheduler/testsuite/test_driver_session_ordering.c (drives the real round with a stand-in allocator emitting one PEND; checks the struct is freed via __asan_address_is_poisoned and the reason is not): RED before, GREEN after
|
|
- Suites: ASAN debug build (src/xce.build.discrete), `meson test --no-suite xceadmin`: 117/117 OK, 0 sanitizer reports; xcelib_test 695 tests 0 failures (2026-09-29)
|
|
- Live: 3-round sequential HA soak on rebuilt ASAN binaries (/home/claude/tmp/xce-bug1885-soak, 2026-09-29): PASS, 15 jobs, zero job loss, all 3 nodes led; SIMVERIFY 4 files 0 mismatches; each recording replays with detect_leaks=1 at exit 0, 0 mismatches; no sanitizer report in the scheduler or controller stderr
|
|
|
|
## References
|
|
- Related: bug-1884
|