myxce/src/frontend/apiserver/backend
lei.chen ff2d784ca9 fix(apiserver): don't free client config C-strings that the C library retains (bug-1501)
tryConnect built the xce_client_config_t with C.CString(host/from/key), then a
defer freed all three. But xcecli_ctx_init stores the config POINTER
(ctx->conf = config), not a copy — client_failover.c dereferences
config->masters/from/key for the client's ENTIRE lifetime (e.g.
xce_failover_next_target strncpy's a master host on every write-fail/redirect).
Freeing the strings left config->masters[0] dangling → ASAN heap-use-after-free
(strncpy in the background C thread) after a few submits.

Fix: keep the three C strings for the process lifetime (tryConnect runs once at
startup, gCtx is a process-global); free them only on the init-failure path.

Verified: 6 consecutive job submits, apiserver stays up, 0 ASAN errors
(previously crashed after ~2-3 submits).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-04 08:59:06 +00:00
..
auth Merge Go frontend (apiserver + xcecli) into meson build 2026-04-14 11:23:18 +08:00
clib.go fix(apiserver): don't free client config C-strings that the C library retains (bug-1501) 2026-08-04 08:59:06 +00:00
config.go Merge branch 'working' into job_peek_lchen 2026-07-22 13:57:25 +08:00
control_host_test.go fix: address P0-2b review issues - build tag and actionType guard 2026-04-17 08:25:05 +00:00
convert.go fix(apiserver): carry exec_user on job submit so jobs don't run as nobody (bug-1500) 2026-08-04 07:38:43 +00:00
convert_pure.go merge 2026-07-23 12:35:10 +08:00
convert_test.go fix(apiserver): carry exec_user on job submit so jobs don't run as nobody (bug-1500) 2026-08-04 07:38:43 +00:00
handler.go fix(schema): rename struct Data -> XceData to unshadow capnp builtin blob type 2026-07-22 09:22:04 +00:00
handler_test.go fix(schema): rename struct Data -> XceData to unshadow capnp builtin blob type 2026-07-22 09:22:04 +00:00
heartbeat.go fix: P1-3 address heartbeat timer leak, test drain, and store consistency 2026-04-17 14:20:02 +00:00
heartbeat_test.go fix: P1-3 address heartbeat timer leak, test drain, and store consistency 2026-04-17 14:20:02 +00:00
integration_test.go fix front end issues 2026-05-01 21:22:45 +08:00
notification.go fix front end issues 2026-05-01 21:22:45 +08:00
peers.go refactor: simplify HA backend peer handling 2026-05-08 03:41:11 +00:00
peers_test.go feat: add HA candidate failover to API server backend 2026-05-08 03:31:35 +00:00
stub.go Init commit of jobs output/error message peek project. 2026-05-09 16:57:54 +08:00
stub_funcs_test.go feat: add HA candidate failover to API server backend 2026-05-08 03:31:35 +00:00
val_helpers.h test(apiserver): add integration tests for P0+P1 backend features 2026-04-18 11:56:31 +00:00
wire_dispatch_support.go fix(schema): rename struct Data -> XceData to unshadow capnp builtin blob type 2026-07-22 09:22:04 +00:00
wire_dispatch_test.go test(job-array-single-wal-record): end-to-end integration test for the compact push 2026-07-15 17:27:34 +00:00