--- id: "bug-1492" status: "fixed" status_updated: "2026-09-24" status_note: "" component: "scheduler" severity: "unknown" timestamp: "2026-08-04T01:04:00Z" last_seen: "2026-09-19T09:30:00Z" occurrences: 1 files: ["src/scheduler/src/plugin.c"] tags: ["scheduler-core", "task-5.2", "plugin-c", "guard-call-mismatch", "pre-existing", "legacy-fcfs-picker"] related: ["bug-1682"] legacy: true --- # bug-1492: plugin_end_session() checks plugin->begin_session_fn != NULL but calls… ## Description plugin_end_session() checks plugin->begin_session_fn != NULL but calls plugin->end_session_fn(plugin) -- a guard/call field mismatch ## Environment _Not recorded (migrated from buglog.json)._ ## Reproduction _Not recorded (migrated from buglog.json)._ ## Root cause Pre-existing bug predating the scheduler-core spec (git blame: commit 638173dec, 2026-02-26). plugin_end_session()'s per-plugin loop guards on the wrong struct field before invoking the hook, so a plugin registering only end_session_fn (not begin_session_fn) never has it called; a plugin registering only begin_session_fn (not end_session_fn) would crash via a NULL function-pointer call if this branch were ever reached for it. Discovered incidentally during scheduler-core task 5.2's independent review while verifying the plugin_begin_session/plugin_end_session per-session bookkeeping fan-out is preserved in the new normal-mode driver loop -- not introduced by task 5.2, confirmed untouched by its diff. ## Fix FIXED (2026-09-19, /xce-audit-invariants scheduler dimension-1 audit, following scheduler-sim-live-allocation). Changed plugin_end_session()'s guard from plugin->begin_session_fn != NULL to plugin->end_session_fn != NULL (src/scheduler/src/plugin.c) -- exactly the one-line fix this entry originally proposed. Confirmed via TDD: added test_end_session_invokes_end_session_fn_when_only_it_is_set() (test_plugin_hook_dispatch.c) registering a plugin with ONLY end_session_fn set, proving it was silently never invoked before the fix (RED, 84/85) and is now correctly invoked (GREEN, 85/85). Duplicate of bug-1682 (same defect, independently re-discovered and re-logged during bug-1681's fix, 2026-08-24) -- this entry (bug-1492, filed 2026-08-04) is the original. Note: this entry's own tags array had been incorrectly stamped "fixed"/"closed-by-scheduler-sim-live-allocation" ahead of the actual fix landing (a bulk-tagging error found by this same audit) -- now genuinely accurate. ## Verification _Not recorded (migrated from buglog.json)._ ## References - Related: bug-1682