You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Environment: Kenshi 1.0.65 (Steam, x64) · RE_Kenshi 0.3.4 · KenshiLua v0.2.8-alpha · Windows 10 Pro 19045
We spent an evening building a companion-banter mod on KenshiLua and hit three separate problems. Each is reproducible on a clean setup (fresh Kenshi reinstall, one probe script in scripts/init/, hot reload disabled). Happy to split this into separate issues if you prefer, and I can share the crash dumps (.dmp) and full logs.
1. onCharsUpdate never reaches Lua scripts
A minimal probe registering 15 notification handlers shows control events firing normally (onKeyDown after 5.4 s, onCharacterSelect after 15.5 s, xpRunning, onCharacterAddOrder, onCharacterIndoorsChanged), while onCharsUpdate produces zero calls over minutes of active gameplay (running, fighting, entering buildings). Registration itself raises no error.
We now use xpRunning as a tick source instead (measured: steady 23–26 calls/sec while moving — works fine).
2. onCharacterIndoorsChanged fires ~3900×/sec and kills the game
With a single registered handler containing only a counter and a log call, loading a save near a walled town produces:
23:36:49.883 call #1
23:36:50.746 call #3370 ← 3370 calls in 0.86 s
~23:36:51 process dies
The handler body does no game calls at all — the dispatch volume alone appears fatal. This coincides with interior/navmesh streaming (Havok log shows interiors being added at that moment). With this event not subscribed, the same save/location plays fine.
3. Reproducible ACCESS_VIOLATION at KenshiLua.dll+0x5c5c8 (v0.2.8)
Three crashes, all at the same instruction, reading near-null (0x1 / 0x4 — looks like a field read through a null/invalid object pointer):
#
When
Faulting thread
Read addr
1
~30 s after a faction encounter; squad under continuous move orders
seconds after an onFactionEncountered → our callback called getName on the faction object
(different tid)
0x1
3
~0.5 s after picking a character up (body equips into a KenshiLua.hand slot); our main-tick resolver called getName + read .quality on the equip event's object
Unsubscribing onPlayerOrderGiven (orders are AI-thread territory; they were streaming ~12/sec) extended survival from ~50 s to ~8 min without changing the crash signature — consistent with per-event probability of hitting the bad path.
Empty scripts/init/ → the same save/session is fully stable (load, run, interiors, alt-tab), so the base stack is fine.
Calling a binding on the object received in a callback (e.g. getName on onFactionEncountered's faction, or on onCharacterEquip's item when the "item" is a picked-up body/hand slot) seems to be the most reliable way to hit it.
Working hypothesis from the dumps: either callbacks are dispatched synchronously on whatever thread raises the game event (and some per-thread state is null off the main thread), or a shared binding entry point dereferences short-lived/invalid event objects. All three dumps funnel into the same instruction either way.
Current workaround in our mod: never call any binding inside an event callback — callbacks only enqueue raw references, and a resolver on the next xpRunning tick does all dereferencing. This plus dropping the two events above got us from ~50 s to 8+ min sessions.
Logs available: KenshiLua.log excerpts for each session, RE_Kenshi crash dumps (crashDump1.0.65_x64.dmp, ~500 KB each, exception stream parsed with a custom minidump reader). Thanks for the project — the binding surface is impressively wide, and with xpRunning as a metronome the scripting side works great.
Environment: Kenshi 1.0.65 (Steam, x64) · RE_Kenshi 0.3.4 · KenshiLua v0.2.8-alpha · Windows 10 Pro 19045
We spent an evening building a companion-banter mod on KenshiLua and hit three separate problems. Each is reproducible on a clean setup (fresh Kenshi reinstall, one probe script in
scripts/init/, hot reload disabled). Happy to split this into separate issues if you prefer, and I can share the crash dumps (.dmp) and full logs.1.
onCharsUpdatenever reaches Lua scriptsA minimal probe registering 15 notification handlers shows control events firing normally (
onKeyDownafter 5.4 s,onCharacterSelectafter 15.5 s,xpRunning,onCharacterAddOrder,onCharacterIndoorsChanged), whileonCharsUpdateproduces zero calls over minutes of active gameplay (running, fighting, entering buildings). Registration itself raises no error.We now use
xpRunningas a tick source instead (measured: steady 23–26 calls/sec while moving — works fine).2.
onCharacterIndoorsChangedfires ~3900×/sec and kills the gameWith a single registered handler containing only a counter and a log call, loading a save near a walled town produces:
The handler body does no game calls at all — the dispatch volume alone appears fatal. This coincides with interior/navmesh streaming (Havok log shows interiors being added at that moment). With this event not subscribed, the same save/location plays fine.
3. Reproducible ACCESS_VIOLATION at
KenshiLua.dll+0x5c5c8(v0.2.8)Three crashes, all at the same instruction, reading near-null (0x1 / 0x4 — looks like a field read through a null/invalid object pointer):
onFactionEncountered→ our callback calledgetNameon the faction objectKenshiLua.handslot); our main-tick resolver calledgetName+ read.qualityon the equip event's objectObservations that may help localize it:
onPlayerOrderGiven(orders are AI-thread territory; they were streaming ~12/sec) extended survival from ~50 s to ~8 min without changing the crash signature — consistent with per-event probability of hitting the bad path.scripts/init/→ the same save/session is fully stable (load, run, interiors, alt-tab), so the base stack is fine.getNameononFactionEncountered's faction, or ononCharacterEquip's item when the "item" is a picked-up body/hand slot) seems to be the most reliable way to hit it.Working hypothesis from the dumps: either callbacks are dispatched synchronously on whatever thread raises the game event (and some per-thread state is null off the main thread), or a shared binding entry point dereferences short-lived/invalid event objects. All three dumps funnel into the same instruction either way.
Current workaround in our mod: never call any binding inside an event callback — callbacks only enqueue raw references, and a resolver on the next
xpRunningtick does all dereferencing. This plus dropping the two events above got us from ~50 s to 8+ min sessions.Logs available:
KenshiLua.logexcerpts for each session, RE_Kenshi crash dumps (crashDump1.0.65_x64.dmp, ~500 KB each, exception stream parsed with a custom minidump reader). Thanks for the project — the binding surface is impressively wide, and withxpRunningas a metronome the scripting side works great.