From ae5b5ba529753c7a653901ffc29b5ea24c3fdf3a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 27 Jul 2020 13:23:05 -0300 Subject: Fixed bug: line hooks in stripped functions Line-hook handling was accessing debug info. without checking whether it was present. --- testes/db.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'testes') diff --git a/testes/db.lua b/testes/db.lua index 941283f7..5377f6ec 100644 --- a/testes/db.lua +++ b/testes/db.lua @@ -884,7 +884,7 @@ end print("testing debug functions on chunk without debug info") -prog = [[-- program to be loaded without debug information +prog = [[-- program to be loaded without debug information (strip) local debug = require'debug' local a = 12 -- a local variable @@ -927,6 +927,23 @@ local f = assert(load(string.dump(load(prog), true))) assert(f() == 13) +do -- bug in 5.4.0: line hooks in stripped code + local function foo () + local a = 1 + local b = 2 + return b + end + + local s = load(string.dump(foo, true)) + local line = true + debug.sethook(function (e, l) + assert(e == "line") + line = l + end, "l") + assert(s() == 2); debug.sethook(nil) + assert(line == nil) -- hook called withoug debug info for 1st instruction +end + do -- tests for 'source' in binary dumps local prog = [[ return function (x) -- cgit v1.2.3-55-g6feb