Fix #150: fresh-install genesis boot SIGSEGV in mem_save #95

Merged
will.anderson merged 1 commits from fix/genesis-boot-crash into hotfix/elc-source-typos 2026-07-21 16:53:55 +00:00
Owner

Genesis (fresh-install) boot segfaulted: engram_save returns Int(0/1) but mem_save str_eq'd it as a String -> EL_CSTR(1)=0x1 -> strcmp derefs 0x1 -> SIGSEGV on a successful first-boot save. Fixed mem_save + handle_api_consolidate to check the Int. PRE-EXISTING (pre-immutability build 1442ce2 crashes identically); not caused by the immutability/floor work. Verified: genesis boot survives (/health 200), verify-soul-contract GATE PASS (both sections), floor preserved. Ship-soul sha256 ac6bd964fafb3f7b8f4c55e168c946654259e336880232a0f8b4efa8ccc89bcd. Do NOT merge — mechanics agent rebuilds from HEAD 091cc1f.

Genesis (fresh-install) boot segfaulted: engram_save returns Int(0/1) but mem_save str_eq'd it as a String -> EL_CSTR(1)=0x1 -> strcmp derefs 0x1 -> SIGSEGV on a successful first-boot save. Fixed mem_save + handle_api_consolidate to check the Int. PRE-EXISTING (pre-immutability build 1442ce2 crashes identically); not caused by the immutability/floor work. Verified: genesis boot survives (/health 200), verify-soul-contract GATE PASS (both sections), floor preserved. Ship-soul sha256 ac6bd964fafb3f7b8f4c55e168c946654259e336880232a0f8b4efa8ccc89bcd. Do NOT merge — mechanics agent rebuilds from HEAD 091cc1f.
will.anderson added 1 commit 2026-07-21 16:51:19 +00:00
A fresh-install (SOUL_CGI_ID=ntn-genesis) boot crashed with
"Segmentation fault: 11" right after the http server came up — a real
customer's very first boot. Backtrace:

  strcmp(0x1) <- str_eq (el_runtime.c:219) <- mem_save <- awareness_run

Root cause: the el runtime's engram_save returns an Int (1 = ok, 0 =
failure), but mem_save did `str_eq(engram_save(path), "")`, treating the
return as a String. str_eq runs EL_CSTR on it, which is a raw cast:
EL_CSTR(1) = (char*)0x1. On a SUCCESSFUL save (return 1) strcmp then
dereferences 0x1 and segfaults. Genesis is the first path that both seeds
the brain AND saves it successfully on the very first awareness pass, so it
crashes there; non-genesis boots (contract gate, refusal test) don't hit a
successful early mem_save, which is why they passed. handle_api_consolidate
had the identical latent bug.

Fix: read engram_save's Int result and compare `== 0` instead of str_eq'ing
it — in mem_save (memory.el) and handle_api_consolidate (neuron-api.el).

Regression: pre-existing, NOT introduced by the immutability/floor rebuild.
The pre-immutability build (1442ce2) genesis-crashes identically in the same
unchanged mem_save; #159 never actually fixed #150 for a release-runtime
build.

Regenerated dist/soul.c + per-module dist/{memory,neuron-api}.c (3GB RSS
watchdog, built against release el_runtime v1.0.0-20260501). Verified:
genesis boot survives (/health 200, no segfault), verify-soul-contract.sh
GATE PASS (PRESENCE + IMMUTABILITY), and the bounded-persona floor is still
compiled in (BOUNDED PERSONA / SOUL_PERSONA_NAME strings present).
will.anderson merged commit 9387c57c3b into hotfix/elc-source-typos 2026-07-21 16:53:55 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: neuron-technologies/neuron#95