From a3186d252f21f5b90f1159c67a117522d17514b4 Mon Sep 17 00:00:00 2001 From: asquared31415 <34665709+asquared31415@users.noreply.github.com> Date: Thu, 18 Dec 2025 16:27:07 -0500 Subject: [PATCH] fix coroutine.wrap in openOS This was causing user programs using coroutine.wrap to ignore errors or in some cases get part of the error message as a string, instead of properly propagating the error like it should. The implementation is copied from machine.lua's sandboxed version of the method. --- .../assets/opencomputers/loot/openos/boot/01_process.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/boot/01_process.lua b/src/main/resources/assets/opencomputers/loot/openos/boot/01_process.lua index 4fc9428eb4..fa40f92698 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/boot/01_process.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/boot/01_process.lua @@ -50,9 +50,14 @@ _coroutine.create = function(f,standAlone) end _coroutine.wrap = function(f) - local thread = coroutine.create(f) + local co = _coroutine.create(f) return function(...) - return select(2, coroutine.resume(thread, ...)) + local result = table.pack(coroutine.resume(co, ...)) + if result[1] then + return table.unpack(result, 2, result.n) + else + error(result[2], 0) + end end end