fix(lua): обёртка тела скрипта в pcall

memory access out of bounds в rbx_8 (Day/Night) — это WASM crash
который пробивает try/catch на JS-стороне. Защита — pcall внутри
самого Lua coroutine: даже если что-то падает в скрипте, ошибка
ловится Lua-side и не доходит до уровня wasmoon resume.

После этого fix остаётся только смотреть кто конкретно крашит —
шлём ошибку через __rbxl_send_error и идём дальше.
This commit is contained in:
min 2026-06-08 15:51:58 +03:00
parent 6bec44d778
commit ee0d91235c

View File

@ -183,8 +183,16 @@ export class LuaSharedSandbox {
Source = nil, Source = nil,
} }
local co = coroutine.create(function() local co = coroutine.create(function()
-- pcall защищает от runtime-ошибок которые иначе крашат
-- coroutine и могут повредить WASM-стейт. Возвраты
-- handler'а намеренно поглощаются.
local ok_, err_ = pcall(function()
${entry.code} ${entry.code}
end) end)
if not ok_ then
__rbxl_send_error(${JSON.stringify(entry.id)}, tostring(err_))
end
end)
__rbxl_register_coroutine(${JSON.stringify(entry.id)}, co) __rbxl_register_coroutine(${JSON.stringify(entry.id)}, co)
local ok, ret = coroutine.resume(co) local ok, ret = coroutine.resume(co)
if not ok then if not ok then