Skip to content

Commit eba327f

Browse files
committed
review修复:eval.dump抛出真实语法错误并pcall保护compat路径;undump失败时安全降级;nls注明适用范围
1 parent ba6a508 commit eba327f

4 files changed

Lines changed: 15 additions & 7 deletions

File tree

extension/package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"lua.debug.launch.console.integratedTerminal.description": "VS Code integrated terminal.",
55
"lua.debug.launch.console.externalTerminal.description": "External terminal that can be configured in user settings.",
66
"lua.debug.launch.luaVersion.description": "Default lua version.",
7-
"lua.debug.launch.syntaxCompatibility.description": "Use the target Lua VM to parse source syntax for breakpoint line information.",
7+
"lua.debug.launch.syntaxCompatibility.description": "Use the target Lua VM to parse source syntax for breakpoint line information. Note: only takes effect for Lua 5.3+ targets and requires a compatible bytecode format.",
88
"lua.debug.launch.luaArch.description": "Default lua arch.",
99
"lua.debug.launch.sourceCoding.description": "Source encoding.",
1010
"lua.debug.launch.path.description": "Search path for Lua programs",

extension/script/backend/worker/eval.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ generate("dump", function()
4646
if luaver.LUAVERSION <= 52 then
4747
local compat_dump = assert(load(readfile 'backend.worker.eval.dump'))
4848
return function(content)
49-
local res, err = compat_dump(content)
50-
if res then
49+
local ok, res, err = pcall(compat_dump, content)
50+
if ok and res ~= nil then
5151
return true, res
5252
end
53-
return false, err
53+
if ok then
54+
return false, 'can not dump function.'
55+
end
56+
return false, res
5457
end
5558
else
5659
local eval_dump = assert(rdebug.load(readfile 'backend.worker.eval.dump'))
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local content = ...
2-
local f = load(content, "=eval.dump")
2+
local f, err = load(content, "=eval.dump")
33
if not f then
4-
return
4+
error(err, 0)
55
end
66
return string.dump(f)

extension/script/backend/worker/parser.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ return function (content, syntaxCompatibility)
110110
log.error("ERROR:"..(err or "unknown error"))
111111
return
112112
end
113-
local cl, v = undump(bin)
113+
local ok, cl, v = pcall(undump, bin)
114+
if not ok then
115+
local log = require 'common.log'
116+
log.error("ERROR:"..tostring(cl))
117+
return
118+
end
114119
version = v
115120
local si = { activelines = {}, definelines = {} }
116121
local lineinfo = {}

0 commit comments

Comments
 (0)