--- id: "bug-1629" status: "fixed" status_updated: "2026-09-24" status_note: "" component: "scheduler" severity: "crash" timestamp: "2026-08-23T08:12:20" last_seen: "2026-09-19T09:00:00Z" occurrences: 1 files: ["src/scheduler/testsuite/test_scheduler_dispatch_commit.c"] tags: ["scheduler", "testsuite", "zarray", "resource-accounting", "asan", "scheduler-dispatch-commit", "test-fixture"] related: [] legacy: true --- # bug-1629: AddressSanitizer SEGV in zarray_get_ex (lib/zarray.c:332) when a test-fixture… ## Description AddressSanitizer SEGV in zarray_get_ex (lib/zarray.c:332) when a test-fixture xce_res_account_t.residx was never resolved from -1 ## Environment _Not recorded (migrated from buglog.json)._ ## Reproduction _Not recorded (migrated from buglog.json)._ ## Root cause zarray_get_ex() only guards idx >= array->caps before indexing array->data[idx]; it does NOT guard idx < 0. sched_update_res_accounts() (resource.c) resolves xce_res_account_t.residx from -1 to a real index via key_find()/add_vres() against core->resmgr ONLY when the host lookup (sched_get_worker()) and the surrounding call chain actually run to completion; if a test fixture never pre-registers the resource name in core->resmgr, sched_update_account()/sched_update_res_accounts() silently swallow the resolution failure (return values are discarded by sched_update_account()) and residx stays -1. A -1 index then passes the 'idx >= array->caps' bounds check (false, since caps starts at 0 too) and falls through to array->data[-1], an out-of-bounds/underflow read that ASAN reports as a high-address SEGV rather than a clean bounds error. ## Fix In the test fixture, pre-register the resource with add_vres(&vres, core.resmgr, RES_NAME, 0) BEFORE calling the real charging path, and use the returned (non-negative) index for get_resvals()/put_resvals() calls, instead of relying on the production code's lazy first-use resolution path inside a minimal test fixture that never loads real resource config. ## Verification _Not recorded (migrated from buglog.json)._ ## References _Not recorded (migrated from buglog.json)._