LuaLanes / lanes

Lanes is a lightweight, native, lazy evaluating multithreading library for Lua 5.1 to 5.4.
Other
465 stars 96 forks source link

__lanesclone mechanism + LuaJIT 2.1 (beta3 or master) on Linda does not work #188

Closed valid-ptr closed 3 years ago

valid-ptr commented 3 years ago

deep_test.lua example crashed while running on LuaJIT OS: Linux x86_64 Lua: luajit (master or 2.1.0-beta3) Lanes: master

This call:

local out = l:get( "key")

gives this backtrace:

#0  0x0000000000421780 in ?? ()
#1  0x0000000000422524 in ?? ()
#2  0x000000000040d908 in lua_getfield ()
#3  0x00007ffff7ff0482 in inter_copy_one (U=0x4000f9f8, L2=0x40000378, L2_cache_i=7, L=0x40020378, i=3, vt=VT_NORMAL, mode_=eLM_FromKeeper, upName_=0x7ffff7ff35ec "?")
    at lanes/src/tools.c:2039
#4  0x00007ffff7ff0906 in luaG_inter_copy (U=0x4000f9f8, L=0x40020378, L2=0x40000378, n=1, mode_=eLM_FromKeeper) at lanes/src/tools.c:2182
#5  0x00007ffff7ff0a5b in luaG_inter_move (U=0x4000f9f8, L=0x40020378, L2=0x40000378, n=1, mode_=eLM_FromKeeper) at lanes/src/tools.c:2210
#6  0x00007ffff7fefc6d in inter_copy_function (U=0x4000f9f8, L2=0x40000378, L2_cache_i=3, L=0x40020378, i=1, vt=VT_NORMAL, mode_=eLM_FromKeeper, upName_=0x7ffff7ff35ec "?")
    at lanes/src/tools.c:1912
#7  0x00007ffff7ff067b in inter_copy_one (U=0x4000f9f8, L2=0x40000378, L2_cache_i=3, L=0x40020378, i=1, vt=VT_NORMAL, mode_=eLM_FromKeeper, upName_=0x7ffff7ff35ec "?")
    at lanes/src/tools.c:2115
#8  0x00007ffff7ff0906 in luaG_inter_copy (U=0x4000f9f8, L=0x40020378, L2=0x40000378, n=1, mode_=eLM_FromKeeper) at anes/src/tools.c:2182
#9  0x00007ffff7ff0a5b in luaG_inter_move (U=0x4000f9f8, L=0x40020378, L2=0x40000378, n=1, mode_=eLM_FromKeeper) at lanes/src/tools.c:2210
#10 0x00007ffff7fe297a in keeper_call (U=0x4000f9f8, K=0x40020378, func_=0x7ffff7fe1bcc <keepercall_get>, L=0x40000378, linda=0x448e70, starting_index=2)
    at lanes/src/keeper.c:816
#11 0x00007ffff7fe87f6 in LG_linda_get (L=0x40000378) at lanes/src/linda.c:519
#12 0x000000000041d9f1 in ?? ()
#13 0x000000000040e23d in lua_pcall ()
#14 0x00007ffff7fe7a0d in LG_linda_protected_call (L=0x40000378) at lanes/src/linda.c:98
#15 0x000000000041d9f1 in ?? ()
#16 0x000000000040e23d in lua_pcall ()
#17 0x00000000004045b0 in ?? ()
#18 0x00000000004053a0 in ?? ()
#19 0x000000000041d9f1 in ?? ()
#20 0x000000000040e2b9 in lua_cpcall ()
#21 0x0000000000404066 in main ()

The same situation with Lua 5.1.5: (I've changed deep_test.c for testing with vanilla 5.1)

#0  0x00000000004077c8 in lua_getmetatable ()
#1  0x00007ffff7ff0336 in inter_copy_one (U=0x452478, L2=0x436010, L2_cache_i=7, L=0x452610, i=5, vt=VT_NORMAL, mode_=eLM_FromKeeper, upName_=0x7ffff7ff34bc "?") at /src/tools.c:2037
#2  0x00007ffff7feed3f in inter_copy_keyvaluepair (U=0x452478, L2=0x436010, L2_cache_i=7, L=0x452610, vt=VT_NORMAL, mode_=eLM_FromKeeper, upName_=0x7ffff7ff34bc "?") at /src/tools.c:1727
#3  0x00007ffff7ff0092 in inter_copy_table (U=0x452478, L2=0x436010, L2_cache_i=7, L=0x452610, i=3, vt=VT_NORMAL, mode_=eLM_FromKeeper, upName_=0x7ffff7ff34bc "?") at /src/tools.c:1995
#4  0x00007ffff7ff057d in inter_copy_one (U=0x452478, L2=0x436010, L2_cache_i=7, L=0x452610, i=3, vt=VT_NORMAL, mode_=eLM_FromKeeper, upName_=0x7ffff7ff34bc "?") at /src/tools.c:2119
#5  0x00007ffff7ff07d6 in luaG_inter_copy (U=0x452478, L=0x452610, L2=0x436010, n=1, mode_=eLM_FromKeeper) at /src/tools.c:2182
#6  0x00007ffff7ff092b in luaG_inter_move (U=0x452478, L=0x452610, L2=0x436010, n=1, mode_=eLM_FromKeeper) at /src/tools.c:2210
#7  0x00007ffff7fefb3d in inter_copy_function (U=0x452478, L2=0x436010, L2_cache_i=3, L=0x452610, i=1, vt=VT_NORMAL, mode_=eLM_FromKeeper, upName_=0x7ffff7ff34bc "?") at /src/tools.c:1912
#8  0x00007ffff7ff054b in inter_copy_one (U=0x452478, L2=0x436010, L2_cache_i=3, L=0x452610, i=1, vt=VT_NORMAL, mode_=eLM_FromKeeper, upName_=0x7ffff7ff34bc "?") at /src/tools.c:2115
#9  0x00007ffff7ff07d6 in luaG_inter_copy (U=0x452478, L=0x452610, L2=0x436010, n=1, mode_=eLM_FromKeeper) at /src/tools.c:2182
#10 0x00007ffff7ff092b in luaG_inter_move (U=0x452478, L=0x452610, L2=0x436010, n=1, mode_=eLM_FromKeeper) at /src/tools.c:2210
#11 0x00007ffff7fe286a in keeper_call (U=0x452478, K=0x452610, func_=0x7ffff7fe1abc <keepercall_get>, L=0x436010, linda=0x4447e0, starting_index=2) at /src/keeper.c:816
#12 0x00007ffff7fe86d6 in LG_linda_get (L=0x436010) at /src/linda.c:519
#13 0x000000000040b07a in luaD_precall ()
#14 0x000000000040b814 in luaD_call ()
#15 0x000000000040a73b in luaD_rawrunprotected ()
#16 0x000000000040baca in luaD_pcall ()
#17 0x00000000004085c6 in lua_pcall ()
#18 0x00007ffff7fe78ed in LG_linda_protected_call (L=0x436010) at /src/linda.c:98

PS Test works as expected with Lua 5.4.2

PPS Switching to 8d097de830d8daf1411cc54ba267f21ecfc3204d gives: PANIC: unprotected error in call to Lua API (ASSERT failed: lanes/src/tools.c:959 '((void *)0) == f && (lua_type(L, (i)) == 5)')

valid-ptr commented 3 years ago

Fixed in PR #190