--- id: "bug-1885" status: "open" status_updated: "2026-09-29" status_note: "newly logged" 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"] --- # 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 TODO: required for fixed/partial ## Fix TODO: required for fixed/partial ## Verification - Test: TODO: name + file; RED before the fix, GREEN after - Suites: TODO: suite results and build profile - Live: TODO: soak/deploy run, or n/a and why ## References - Related: bug-1884