myxce/.wolf/bugs/bug-1574.md
Rongsong Shen 4c13412720
chore: sync harness batch and bug-1872/1874-1877 to Gitea (#298-#315)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 04:42:34 +00:00

3.3 KiB

id status status_updated status_note component severity timestamp last_seen occurrences files tags related fix_commits legacy gitea_issue gitea_synced_status gitea_synced_hash
bug-1574 fixed 2026-09-28 controller crash 2026-08-17T18:55:00Z 2026-09-19T09:00:00Z 1
src/harness/test.c
src/harness/resval_typeresolve.c
resupdate
cmd_resupdate
set_resval
segfault
uninitialized-stack-memory
Value_u_svalue
test.c
pre-existing
resource-value-verification
bug-1570
bug-1573
da1a663f
true 298 fixed 296e09085090

bug-1574: xce_test segfaults (SIGSEGV, exit 139) immediately on 'resupdate -n model -v ' (and by the…

Description

xce_test segfaults (SIGSEGV, exit 139) immediately on 'resupdate -n model -v ' (and by the same code path, -n type) run in the worker context against a live controller -- no output printed before the crash

Environment

Not recorded (migrated from buglog.json).

Reproduction

Not recorded (migrated from buglog.json).

Root cause

Pre-existing, predates the resource-value-verification feature entirely (confirmed via git show on the pre-task-2.1 baseline commit 98b8c34b^: the original set_resval()'s switch(valtype) already had no case for Value_u_svalue, same shape as today). set_resval() only assigns vals[idx].name inside a case block of switch(valtype); Value_u_svalue (type/model) has no case, so for these two names vals[idx].name is never assigned and keeps whatever uninitialized garbage was already on the local stack array xce_resval_t vals[MAX_N_RES] (never zero-initialized) in cmd_resupdate(). That garbage pointer is then passed unconditionally into xcecli_update_resvals()'s wire encoder inside &valptrs[0], which (most likely) dereferences it as a C string, causing the segfault. Task 2.1's own comment at test.c (near set_resval, 'the switch falls through with vals[idx].name/.val->which left unset ... intentionally not fixed by this task, see CONCERNS') already flagged this exact gap and deliberately preserved it byte-for-byte per Requirement 1.4, rather than introducing it. Discovered live during resource-value-verification task 4.2's validation (apiserver trace-log addition, live-testing the string-value code path with resupdate -n model -v CustomModelX) -- unrelated to task 4.2's own change (src/frontend/apiserver/backend/handler.go), which only touches Go/apiserver code.

Fix

set_resval() moved out of test.c as resval_fill() in src/harness/resval_typeresolve.c, which fills name, host and value for every type, including Value_u_svalue (a copied string; "" when no -v). cmd_resupdate() also zero-initializes vals[] and frees each entry afterwards (resval_fill_release()).

Verification

  • Test: test_fill_string_resource_sets_name_and_value, test_fill_numeric_resource, test_fill_string_override_without_value_is_empty_string in src/harness/testsuite/test_resval_typeresolve.c (the first pre-fills the struct with 0xA5 like the old uninitialized stack array); the functions did not exist before the fix, and the old set_resval() had no svalue case at all
  • Suites: harness 6/6 (asan): harness_unit_test 141/0, cmdutil 14/0, resval_typeresolve 7/0, joblist_display 22/0, join_worker_args 7/0, listrow_json 12/0
  • Live: n/a; xce_test is a client tool and every case above runs without a controller

References

  • Related: bug-1570, bug-1573