myxce/src
Rongsong Shen b406dd762a
fix(controller): sched_worker_change() use-after-free on worker disconnect (bug-1578)
sched_worker_change() aliased w->host.resvals_to_sched to a local xlist_t's
backing array, pushed it to the scheduler, then freed that array via
xlist_fini() without resetting the alias - leaving a dangling pointer for
the rest of the worker's life. On disconnect (handle_worker_leave ->
mark_worker_unavail -> persist_worker_hook_fun -> capnp_encode_worker ->
encode_Worker -> encode_NameValue_list), this dereferenced freed memory and
crashed the controller - but only once a scheduler had ever connected
(on_scheduler_join gates the hook registration), which made it easy to miss
in isolated worker-only testing.

The correct reset already existed in the function but was dead-code'd
behind #if 0 /*FIXME*/ - apparently from a prior fix attempt that got
wrapped instead of landed. Fix mirrors the proven-correct pattern already
used by the sibling apiserver_worker_change(): null the alias before
xlist_fini() frees the backing array, rather than double-freeing via
free_name_val_list() first.

Adds test_sched_worker_change.c, a regression test driving the real
production hook-dispatch path (xce_run_hooks -> sched_worker_hook_fun ->
sched_worker_dead -> sched_worker_change) and the real encode_Worker()
encoder the original crash traversed - confirmed to reproduce the exact
ASAN heap-use-after-free when the fix is reverted, and pass clean when
restored, closing the gap that let this regress silently once already.

Found while live-testing the resource-value-verification feature (deploying
a scheduler + injecting worker resource values via xce_test, then
disconnecting) - unrelated to that feature's own changes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-18 08:15:37 +00:00
..
autoscaler support shared libxce(for api server) 2026-01-19 11:02:49 +08:00
configs fix(controller): close 6 data-safety races + apply-pump O(N^2) regression + boot TOCTOU 2026-08-16 10:20:02 +00:00
controller fix(controller): sched_worker_change() use-after-free on worker disconnect (bug-1578) 2026-08-18 08:15:37 +00:00
docs update documents 2026-08-10 17:51:51 +08:00
frontend feat(resource-value-verification): add apiserver resval trace log (task 4.2) 2026-08-18 02:51:34 +00:00
include fix(ha): close standby election-freeze (bug-1562) + flusher retry storm (bug-1563) 2026-08-17 06:35:06 +00:00
lib fix(libxce): bug-1425 -- populate jobsubmit's *jobid on idempotent-replay success 2026-08-16 10:47:09 +00:00
nixSupport feat(scheduler-core): implement REPL execution control (task 12.1) 2026-08-07 08:17:35 +00:00
scheduler feat(resource-value-verification): add scheduler resval trace log (task 4.1) 2026-08-18 01:49:25 +00:00
schema refactor(controller,xceadmin): drop generic Resource.unit, hardcode bytes for maxmem 2026-08-13 08:27:16 +00:00
tools feat(resource-value-verification): extend xce-deploy-ha with apiserver step + start-all.sh (task 3.1) 2026-08-18 00:53:49 +00:00
worker fix(worker): bug-1569 periodic resval reports tagged with wrong host 2026-08-17 12:01:52 +00:00
xceadmin feat(deploy,xceadmin): standalone xceadmin packaging + deploy-ha usability (bug-1566) 2026-08-17 10:20:52 +00:00
flake.lock fix librtti package leak issue 2026-07-27 15:31:50 +08:00
flake.nix save works 2026-03-04 18:18:53 +08:00
meson.build feat(admin-config-tool): wire xceadmin into meson + nix build 2026-07-22 10:46:45 +00:00
meson.options Merge Go frontend (apiserver + xcecli) into meson build 2026-04-14 11:23:18 +08:00