diff options
| author | ruki <[email protected]> | 2025-04-27 23:51:56 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-08-28 11:35:53 +0800 |
| commit | 568e22b7879e47616ba96e35a750cf950321742c (patch) | |
| tree | 97db472b586be75c50ac3a20d9d5aafa81eab81c /xmake/core/thread/thread.lua | |
| parent | 8b976dd744fc18d617e00655631cbca8a1f19035 (diff) | |
fix thread envs
Diffstat (limited to 'xmake/core/thread/thread.lua')
| -rw-r--r-- | xmake/core/thread/thread.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/xmake/core/thread/thread.lua b/xmake/core/thread/thread.lua index dcb74e282..19546c878 100644 --- a/xmake/core/thread/thread.lua +++ b/xmake/core/thread/thread.lua @@ -93,7 +93,8 @@ function _instance:start() -- serialize and pass callback and arguments to this thread -- we do not use string.serialize to serialize callback, because it's slower (deserialize) - local callinfo = string._dump(self._CALLBACK, true) + -- and we cannot strip function debug info, we need to reserve _ENV, and other upvalue names + local callinfo = string._dump(self._CALLBACK) local argv = self._ARGV if argv ~= nil then callinfo = string.serialize(argv, {strip = true, indent = false}) .. "<Argv\27>" .. callinfo @@ -217,10 +218,10 @@ function thread._run_thread(callinfo_str) end -- load callback - local fenv = debug.getfenv(debug.getinfo(2, "f").func) local callback + local fenvs = {} if callback_str then - local script, errors = load(callback_str, "=(thread)", "b", fenv) + local script, errors = load(callback_str, "=(thread)", "b", fenvs) if not script then return false, string.format("cannot load thread callback, %s!", errors or "unknown") end |
