Memory corruption in in luaV_execute (lua/Test_lua/lua/lvm.c:1784)
###### Lua revision
version : Lua 5.4.0
###### Build platform
Ubuntu 18.10 LTS (Linux ubuntu 4.18.0-25-generic x86_64)
###### Build steps
```
add -fsanitize=address -g to CFLAGS
make
```
###### Test case
Memory_corruption_luaV_execute.lua
```
function main()
v4 = {13.37 }
v6 = {"function" ,1337 ,v4,assert,13.37 ,-2 ,v4,v4}
v12 = {1337 ,1337 ,1337 ,1337 ,1337 }
v13 = {a=1337 ,b=getmetatable,c="number" ,d=v12}
v14 = {a=getmetatable,c=v13,d=v13,e=getmetatable,length=getmetatable}
local v16 = 1337
function v19(v20,v21,v22,v23)
v25 = {0 ,13.37 }
function v27(v28,v29,v30,v31)
local v32 = -3852123798
if (v28) then
v33 = pcall
v32 = rawget
else
v32 = v14
end
local v35 = 13.37
v36 = v31(getmetatable)
v40 = string.sub("length" ,-1 ,-1 )
v41 = {13.37 ,13.37 }
v42 = v41[-3978136795]
v43 = 13.37
v44 = "dRDPeQXJ+A"
v45 = string
v46 = -846484919
local v49 = 0
while (v49 < 0 ) do
v50 = v49 + 1
v49 = v50
end
return v27
end
v53 = "config" --/ /Tq/ygu
v54 = v25[-3978136795]
return v13
end
v55 = string.dump(v19)
v56 = string.format(v55,v16,v6)
v58 = load(v56)
v59 = load(v58)
-- Stderr:
end
main()
```
###### Execution steps
```
$ ls
Memory_corruption_luaV_execute.lua
$ ./Test_lua/lua/lua ./crashes/Memory_corruption_luaV_execute.lua
AddressSanitizer:DEADLYSIGNAL
=================================================================
==6373==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x5602093d3815 bp 0x00000000024f sp 0x7fffcbf6d6e0 T0)
==6373==The signal is caused by a READ memory access.
==6373==Hint: address points to the zero page.
#0 0x5602093d3814 in luaV_execute /home/test/Lua/Test_lua/lua/lvm.c:1784
#1 0x5602093ac605 in luaD_callnoyield /home/test/Lua/Test_lua/lua/ldo.c:525
#2 0x5602093a2d34 in lua_callk /home/test/Lua/Test_lua/lua/lapi.c:987
#3 0x5602093ee57d in generic_reader /home/test/Lua/Test_lua/lua/lbaselib.c:352
#4 0x5602093dfc5e in luaZ_fill /home/test/Lua/Test_lua/lua/lzio.c:28
#5 0x5602093a9a17 in f_parser /home/test/Lua/Test_lua/lua/ldo.c:789
#6 0x5602093a9c51 in luaD_rawrunprotected /home/test/Lua/Test_lua/lua/ldo.c:148
#7 0x5602093ad1e0 in luaD_pcall /home/test/Lua/Test_lua/lua/ldo.c:749
#8 0x5602093ad598 in luaD_protectedparser /home/test/Lua/Test_lua/lua/ldo.c:813
#9 0x5602093a341c in lua_load /home/test/Lua/Test_lua/lua/lapi.c:1061
#10 0x5602093eed4d in luaB_load /home/test/Lua/Test_lua/lua/lbaselib.c:379
#11 0x5602093ac25c in luaD_call /home/test/Lua/Test_lua/lua/ldo.c:481
#12 0x5602093d4824 in luaV_execute /home/test/Lua/Test_lua/lua/lvm.c:1614
#13 0x5602093d4824 in luaV_execute /home/test/Lua/Test_lua/lua/lvm.c:1614
#14 0x5602093ac605 in luaD_callnoyield /home/test/Lua/Test_lua/lua/ldo.c:525
#15 0x5602093a9c51 in luaD_rawrunprotected /home/test/Lua/Test_lua/lua/ldo.c:148
#16 0x5602093ad1e0 in luaD_pcall /home/test/Lua/Test_lua/lua/ldo.c:749
#17 0x5602093a2f8f in lua_pcallk /home/test/Lua/Test_lua/lua/lapi.c:1031
#18 0x56020939c42a in docall /home/test/Lua/Test_lua/lua/lua.c:139
#19 0x56020939d79d in handle_script /home/test/Lua/Test_lua/lua/lua.c:228
#20 0x56020939d79d in pmain /home/test/Lua/Test_lua/lua/lua.c:603
#21 0x5602093ac25c in luaD_call /home/test/Lua/Test_lua/lua/ldo.c:481
#22 0x5602093ac605 in luaD_callnoyield /home/test/Lua/Test_lua/lua/ldo.c:525
#23 0x5602093a9c51 in luaD_rawrunprotected /home/test/Lua/Test_lua/lua/ldo.c:148
#24 0x5602093ad1e0 in luaD_pcall /home/test/Lua/Test_lua/lua/ldo.c:749
#25 0x5602093a2f8f in lua_pcallk /home/test/Lua/Test_lua/lua/lapi.c:1031
#26 0x56020939bbda in main /home/test/Lua/Test_lua/lua/lua.c:629
#27 0x7f13ec0c709a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
#28 0x56020939c239 in _start (/home/test/Lua/Test_lua/lua/lua+0x18239)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/test/Lua/Test_lua/lua/lvm.c:1784 in luaV_execute
==6373==ABORTING
```
###### Backtrace
```
$ gdb -q -args ./Test_lua/lua/lua ./crashes/Memory_corruption_luaV_execute.lua
Reading symbols from ./Test_lua/lua/lua...done.
(gdb) r
Starting program: /home/test/Lua/Test_lua/lua/lua ./crashes/Memory_corruption_luaV_execute.lua
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00005555555a3815 in luaV_execute (L=L@entry=0x61b000000088, ci=<optimized out>) at lvm.c:1783
1783 Proto *p = cl->p->p[GETARG_Bx(i)];
(gdb) x/5i $rip
=> 0x5555555a3815 <luaV_execute+6709>: mov (%rdi),%r14
0x5555555a3818 <luaV_execute+6712>: shr $0x3,%rax
0x5555555a381c <luaV_execute+6716>: cmpb $0x0,0x7fff8000(%rax)
0x5555555a3823 <luaV_execute+6723>: jne 0x5555555aedfc <luaV_execute+53276>
0x5555555a3829 <luaV_execute+6729>: lea 0x8(%r11),%rdi
(gdb) p/x $rdi
$1 = 0x0
```