forked from lei.chen/myxce
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> |
||
|---|---|---|
| .. | ||
| auth | ||
| clib.go | ||
| config.go | ||
| control_host_test.go | ||
| convert.go | ||
| convert_pure.go | ||
| convert_test.go | ||
| handler.go | ||
| handler_test.go | ||
| heartbeat.go | ||
| heartbeat_test.go | ||
| integration_test.go | ||
| notification.go | ||
| peers.go | ||
| peers_test.go | ||
| stub.go | ||
| stub_funcs_test.go | ||
| val_helpers.h | ||
| wire_dispatch_support.go | ||
| wire_dispatch_test.go | ||