myxce/.wolf
Rongsong Shen b040dfc068
fix(scheduler): remove double-free in limit plugin config update (bug-1685)
User-reported live crash: xce_scheduler SIGABRT via glibc malloc_printerr
(heap corruption) inside kill_limit(), called from limit_update_config()
during a live config reload.

limit_update_config() called kill_limit(limit) in its error path after a
failed key_add(privdata->limits, ...). But privdata->limits is a kvmgr
created with .datakiller = kill_limit, so on a kvtab-level failure (e.g.
-EEXIST for a duplicate limit name -- exactly the rc=-17 captured in the
crash's own backtrace), xkvmgr_add() already rolls back via vclear() ->
xzarray_clear(), which fires kill_limit(limit) once automatically. The
caller's explicit second call was a double free.

Removed the redundant call; the kvmgr's own configured datakiller already
owns cleanup on this failure path (mirrors the ownership asymmetry
job.c's restore_job_array() already documents for the opposite case,
where its kvmgr has no datakiller configured and the caller must free
failed items itself). One accepted, documented residual gap: a vstore()-
level OOM failure (never reaching the kvtab step) would leak `limit`
instead -- vanishingly rare, and a leak is strictly better than the
guaranteed crash on the common duplicate-name case; xkvmgr_add's return
code doesn't distinguish which sub-case occurred, so there's no clean way
to free conditionally without a kvmgr API change (out of scope).

New test_limit_plugin.c (this plugin had zero test coverage before) --
RED-phase independently reproduced a genuine ASAN heap-use-after-free
matching the live crash's exact call chain; GREEN confirms 0 failures.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AgYRU3zDTqNGV5Jk8aiKLg
2026-08-25 08:18:34 +00:00
..
hooks chore(wolf): sync anatomy/cerebrum/memory/hooks/token-ledger bookkeeping 2026-08-25 06:40:25 +00:00
_scan-state.json commit wolf status 2026-08-17 06:35:54 +00:00
anatomy-index.json commit wolf status 2026-08-17 06:35:54 +00:00
anatomy.md chore(wolf): sync anatomy/cerebrum/memory/hooks/token-ledger bookkeeping 2026-08-25 06:40:25 +00:00
buglog.json fix(scheduler): remove double-free in limit plugin config update (bug-1685) 2026-08-25 08:18:34 +00:00
cerebrum.md chore(wolf): sync anatomy/cerebrum/memory/hooks/token-ledger bookkeeping 2026-08-25 06:40:25 +00:00
config.json chore: checkpoint all prior work for clean state 2026-06-04 13:04:16 +00:00
cron-manifest.json chore: checkpoint all prior work for clean state 2026-06-04 13:04:16 +00:00
cron-state.json save wolf status 2026-08-18 14:50:44 +00:00
daemon.log save wolf status 2026-08-18 14:50:44 +00:00
designqc-report.json chore: checkpoint all prior work for clean state 2026-06-04 13:04:16 +00:00
identity.md chore: checkpoint all prior work for clean state 2026-06-04 13:04:16 +00:00
memory.md chore(wolf): sync anatomy/cerebrum/memory/hooks/token-ledger bookkeeping 2026-08-25 06:40:25 +00:00
OPENWOLF.md chore(wolf): guard buglog.json integrity, add dedupe rule and auto-checkpoint 2026-08-13 04:28:44 +00:00
reframe-frameworks.md chore: checkpoint all prior work for clean state 2026-06-04 13:04:16 +00:00
suggestions.json chore(wolf): checkpoint session state (anatomy, cerebrum, memory, scan-state) 2026-08-16 11:02:17 +00:00
token-ledger.json chore(wolf): sync anatomy/cerebrum/memory/hooks/token-ledger bookkeeping 2026-08-25 06:40:25 +00:00