From 3ad5d90d0de2bfca6ef17b10202df070e660e3c3 Mon Sep 17 00:00:00 2001 From: t Date: Fri, 3 Jul 2026 13:01:25 -0600 Subject: segfault fix --- libpanto-lua/src/module.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libpanto-lua/src/module.zig b/libpanto-lua/src/module.zig index 910334f..a707ecd 100644 --- a/libpanto-lua/src/module.zig +++ b/libpanto-lua/src/module.zig @@ -488,7 +488,8 @@ fn buildAgent(L: *c.lua_State, box: *AgentBox) ConfigError!void { ) catch return error.AgentInit; // Pin the store after Agent.init succeeds; the agent/session borrow it. - c.lua_pushvalue(L, -1); + // `luaL_ref` pops the store userdata, leaving the newly created Agent + // userdata on top for `agentNew` to return. box.store_ref = c.luaL_ref(L, LUA_REGISTRYINDEX); // Ownership of the inner conversation moved into the agent; neuter the -- cgit v1.3