Undefined behavior in luaO_applyparam()
Sergey Bronnikov <[email protected]>
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <[email protected]> |
Hello,
there is an issue with undefined behavior in lobject.c:
lobject.c:99:22: runtime error: left shift of negative value -2070
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior lobject.c:99:22
How to reproduce:
1. git clone https://github.com/lua/lua
2. cd lua
3. make all CC=clang MYCFLAGS="-std=c99 -DLUA_USE_LINUX -m32
-fsanitize=undefined -fno-sanitize-recover=all -O1 -g" MYLDFLAGS="-m32
-fsanitize=undefined -g" MYLIBS="-lm"
4. create a file with Lua chunk:
cat << EOF > gc.lua
local unpack = unpack or table.unpack
local function band(x, ...)
local chunk = "return " .. x
for _, v in ipairs({...}) do chunk = chunk .. " & " .. v end
return assert(load(chunk))()
end
local function build_table(n)
local t = {}
for i = 1, n do table.insert(t, i) end
return t
end
local function fn(param, val)
local data = {}
local _ = { data }
collectgarbage("param", param, val)
local band_args = build_table(450)
local _ = band(unpack(band_args))
end
fn("majorminor", 3054)
fn("pause", 65)
fn("pause", 65)
EOF
5. ./lua gc.lua
lobject.c:99:22: runtime error: left shift of negative value -2070
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior lobject.c:99:22
PUC Rio Lua 5.5.1, 7579fc9d7ed90240487251dfb69168f8e64e9294
Sergey
--
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/7b043404-ddb3-454c-9253-69aa23a7e5f1n%40googlegroups.com.