diff --git a/src/lib_base.c b/src/lib_base.c index 1cd83058..83c7663c 100644 --- a/src/lib_base.c +++ b/src/lib_base.c @@ -502,7 +502,8 @@ LJLIB_CF(print) lua_gettable(L, LUA_GLOBALSINDEX); tv = L->top-1; } - shortcut = (tvisfunc(tv) && funcV(tv)->c.ffid == FF_tostring); + shortcut = (tvisfunc(tv) && funcV(tv)->c.ffid == FF_tostring) + && !gcrefu(basemt_it(G(L), LJ_TNUMX)); for (i = 0; i < nargs; i++) { cTValue *o = &L->base[i]; const char *str; diff --git a/src/lj_asm.c b/src/lj_asm.c index ff07b7ee..c4c5dfdd 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c @@ -22,7 +22,6 @@ #include "lj_ircall.h" #include "lj_iropt.h" #include "lj_mcode.h" -#include "lj_iropt.h" #include "lj_trace.h" #include "lj_snap.h" #include "lj_asm.h" diff --git a/src/lj_clib.c b/src/lj_clib.c index f016b06b..a7df719a 100644 --- a/src/lj_clib.c +++ b/src/lj_clib.c @@ -119,12 +119,13 @@ static void *clib_loadlib(lua_State *L, const char *name, int global) RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); if (!h) { const char *e, *err = dlerror(); - if (*err == '/' && (e = strchr(err, ':')) && + if (err && *err == '/' && (e = strchr(err, ':')) && (name = clib_resolve_lds(L, strdata(lj_str_new(L, err, e-err))))) { h = dlopen(name, RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); if (h) return h; err = dlerror(); } + if (!err) err = "dlopen failed"; lj_err_callermsg(L, err); } return h; @@ -384,6 +385,7 @@ TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name) cd = lj_cdata_new(cts, id, CTSIZE_PTR); *(void **)cdataptr(cd) = p; setcdataV(L, tv, cd); + lj_gc_anybarriert(L, cl->cache); } } return tv; diff --git a/src/lj_def.h b/src/lj_def.h index b1208f6b..9d09e846 100644 --- a/src/lj_def.h +++ b/src/lj_def.h @@ -262,19 +262,19 @@ static LJ_AINLINE uint32_t lj_fls(uint32_t x) return _CountLeadingZeros(x) ^ 31; } #else -unsigned char _BitScanForward(uint32_t *, unsigned long); -unsigned char _BitScanReverse(uint32_t *, unsigned long); +unsigned char _BitScanForward(unsigned long *, unsigned long); +unsigned char _BitScanReverse(unsigned long *, unsigned long); #pragma intrinsic(_BitScanForward) #pragma intrinsic(_BitScanReverse) static LJ_AINLINE uint32_t lj_ffs(uint32_t x) { - uint32_t r; _BitScanForward(&r, x); return r; + unsigned long r; _BitScanForward(&r, x); return (uint32_t)r; } static LJ_AINLINE uint32_t lj_fls(uint32_t x) { - uint32_t r; _BitScanReverse(&r, x); return r; + unsigned long r; _BitScanReverse(&r, x); return (uint32_t)r; } #endif diff --git a/src/lj_lex.c b/src/lj_lex.c index 2d2f8194..fb3d95ee 100644 --- a/src/lj_lex.c +++ b/src/lj_lex.c @@ -138,7 +138,7 @@ static int lex_skipeq(LexState *ls) int count = 0; LexChar s = ls->c; lua_assert(s == '[' || s == ']'); - while (lex_savenext(ls) == '=') + while (lex_savenext(ls) == '=' && count < 0x20000000) count++; return (ls->c == s) ? count : (-count) - 1; } diff --git a/src/lj_record.c b/src/lj_record.c index 7f37d6c6..4a50de1b 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -1860,6 +1860,8 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults) lj_trace_err_info(J, LJ_TRERR_NYIBC); } } + if (J->baseslot + J->maxslot >= LJ_MAX_JSLOTS) + lj_trace_err(J, LJ_TRERR_STACKOV); } /* -- Record allocations -------------------------------------------------- */ diff --git a/src/lj_tab.c b/src/lj_tab.c index c51666d3..e77a7af5 100644 --- a/src/lj_tab.c +++ b/src/lj_tab.c @@ -486,8 +486,7 @@ TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key) /* Rechain pseudo-resurrected string keys with colliding hashes. */ while (nextnode(freenode)) { Node *nn = nextnode(freenode); - if (tvisstr(&nn->key) && !tvisnil(&nn->val) && - hashstr(t, strV(&nn->key)) == n) { + if (!tvisnil(&nn->val) && hashkey(t, &nn->key) == n) { freenode->next = nn->next; nn->next = n->next; setmref(n->next, nn); @@ -500,9 +499,9 @@ TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key) ** any string key that's currently in a non-main positions. */ while ((nn = nextnode(freenode))) { - if (tvisstr(&nn->key) && !tvisnil(&nn->val)) { - Node *mn = hashstr(t, strV(&nn->key)); - if (mn != freenode) { + if (!tvisnil(&nn->val)) { + Node *mn = hashkey(t, &nn->key); + if (mn != freenode && mn != nn) { freenode->next = nn->next; nn->next = mn->next; setmref(mn->next, nn);