-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doesn't work with a release
built yk
#6
Comments
(works ok with a debug yk) |
I was wrong. As soon as I set |
The failures are to do with the I got it working with the following hacks (from Lukas): diff --git a/src/lapi.c b/src/lapi.c
index 5ee6579..d1ec425 100644
--- a/src/lapi.c
+++ b/src/lapi.c
@@ -57,7 +57,7 @@ const char lua_ident[] =
** Convert an acceptable index to a pointer to its respective value.
** Non-valid indices return the special nil value 'G(L)->nilvalue'.
*/
-static TValue *index2value (lua_State *L, int idx) {
+TValue *index2value (lua_State *L, int idx) {
CallInfo *ci = L->ci;
if (idx > 0) {
StkId o = ci->func + idx;
diff --git a/src/lauxlib.c b/src/lauxlib.c
index 8ed1da1..3d79fcc 100644
--- a/src/lauxlib.c
+++ b/src/lauxlib.c
@@ -543,7 +543,7 @@ static size_t newbuffsize (luaL_Buffer *B, size_t sz) {
** 'B'. 'boxidx' is the relative position in the stack where is the
** buffer's box or its placeholder.
*/
-static char *prepbuffsize (luaL_Buffer *B, size_t sz, int boxidx) {
+char *prepbuffsize (luaL_Buffer *B, size_t sz, int boxidx) {
checkbufferlevel(B, boxidx);
if (B->size - B->n >= sz) /* enough space? */
return B->b + B->n;
@@ -1008,7 +1008,7 @@ LUALIB_API const char *luaL_gsub (lua_State *L, const char *s,
}
-static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
+void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
(void)ud; (void)osize; /* not used */
if (nsize == 0) {
free(ptr);
diff --git a/src/lbaselib.c b/src/lbaselib.c
index 1d60c9d..71d9881 100644
--- a/src/lbaselib.c
+++ b/src/lbaselib.c
@@ -422,7 +422,7 @@ static int luaB_dofile (lua_State *L) {
}
-static int luaB_assert (lua_State *L) {
+int luaB_assert (lua_State *L) {
if (l_likely(lua_toboolean(L, 1))) /* condition is true? */
return lua_gettop(L); /* return all arguments */
else { /* error */
diff --git a/src/ldo.c b/src/ldo.c
index a48e35f..3a2ae16 100644
--- a/src/ldo.c
+++ b/src/ldo.c
@@ -476,7 +476,7 @@ void luaD_poscall (lua_State *L, CallInfo *ci, int nres) {
#define next_ci(L) (L->ci->next ? L->ci->next : luaE_extendCI(L))
-l_sinline CallInfo *prepCallInfo (lua_State *L, StkId func, int nret,
+/*l_sinline*/ CallInfo *prepCallInfo (lua_State *L, StkId func, int nret,
int mask, StkId top) {
CallInfo *ci = L->ci = next_ci(L); /* new frame */
ci->func = func;
@@ -490,7 +490,7 @@ l_sinline CallInfo *prepCallInfo (lua_State *L, StkId func, int nret,
/*
** precall for C functions
*/
-l_sinline int precallC (lua_State *L, StkId func, int nresults,
+/*l_sinline*/ int precallC (lua_State *L, StkId func, int nresults,
lua_CFunction f) {
int n; /* number of returns */
CallInfo *ci;
diff --git a/src/llimits.h b/src/llimits.h
index 52a32f9..2622261 100644
--- a/src/llimits.h
+++ b/src/llimits.h
@@ -176,7 +176,7 @@ typedef LUAI_UACINT l_uacInt;
#define l_inline /* empty */
#endif
-#define l_sinline static l_inline
+#define l_sinline /*l_inline*/
/*
diff --git a/src/lstring.c b/src/lstring.c
index 13dcaf4..41333bb 100644
--- a/src/lstring.c
+++ b/src/lstring.c
@@ -140,7 +140,7 @@ void luaS_init (lua_State *L) {
/*
** creates a new string object
*/
-static TString *createstrobj (lua_State *L, size_t l, int tag, unsigned int h) {
+TString *createstrobj (lua_State *L, size_t l, int tag, unsigned int h) {
TString *ts;
GCObject *o;
size_t totalsize; /* total size of TString object */
@@ -185,7 +185,7 @@ static void growstrtab (lua_State *L, stringtable *tb) {
/*
** Checks whether short string exists and reuses it or creates a new one.
*/
-static TString *internshrstr (lua_State *L, const char *str, size_t l) {
+TString *internshrstr (lua_State *L, const char *str, size_t l) {
TString *ts;
global_State *g = G(L);
stringtable *tb = &g->strt;
diff --git a/src/lstrlib.c b/src/lstrlib.c
index 0b4fdbb..aa14817 100644
--- a/src/lstrlib.c
+++ b/src/lstrlib.c
@@ -147,7 +147,7 @@ static int str_upper (lua_State *L) {
}
-static int str_rep (lua_State *L) {
+int str_rep (lua_State *L) {
size_t l, lsep;
const char *s = luaL_checklstring(L, 1, &l);
lua_Integer n = luaL_checkinteger(L, 2);
diff --git a/src/luaconf.h b/src/luaconf.h
index d42d14b..be94ffb 100644
--- a/src/luaconf.h
+++ b/src/luaconf.h
@@ -11,6 +11,7 @@
#include <limits.h>
#include <stddef.h>
+#define static
/*
** ===================================================================
@@ -307,7 +308,7 @@
*/
#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
defined(__ELF__) /* { */
-#define LUAI_FUNC __attribute__((visibility("internal"))) extern
+#define LUAI_FUNC /*__attribute__((visibility("internal")))*/ extern
#else /* }{ */
#define LUAI_FUNC extern
#endif /* } */ We should think about better ways of doing this. Perhaps we should nullify |
I also needed to use the patch above to get yklua working. |
Based on the diff in: ykjit#6
Based on the diff in: ykjit#6
#8 solves most of this. Only |
Closing in favour of ykjit/yk#659 |
64: Track initialised yk locations r=ltratt a=Pavel-Durov Partially fixes (only for serial compilation) - #62 # Changes - Remove reallocarray in favour of calloc - Change YkLocations to be stored as pointers - Change lyk interface to reflect its "hooks" functionality - Move tests to a separate test script and enable serialised all.lua test suite - Added logging in lyk module for ease of debugging - Updated readme `test.sh` was tested for resiliency multiple times: ```shell $ try_repeat -v 100 sh ./test.sh ``` # Issues ## Uninitialised locations memory `reallocarray` does not initialise memory with default zero bytes locations as `calloc`. Moving to `calloc` and using pointers allowed to check for NULL with default values set at initialisation time. ## Tests When lua tests are executed one by one as single files it produces different results from when it's executed via `all.lua` test suite. Example: ```shell $ YKD_SERIALISE_COMPILATION=1 ../src/lua -e"_U=true" ./main.lua ... ../src/lua: ./main.lua:343: assertion failed! stack traceback: [C]: in function 'assert' ./main.lua:343: in main chunk [C]: in ? ``` When run through `all.lua` it passes: ```shell $ YKD_SERIALISE_COMPILATION=1 ../src/lua -e"_U=true" ./all.lua ... ***** FILE 'main.lua'***** ... ***** FILE 'gc.lua'***** ... ``` Since `all.lua` is what we base the stability of yklua, I think we should include it in the tests as is, currently only serialised compilation works. Running `all.lua` prior to these changes results in error (`main/56c5787799b876f36babbae24e9afc025806b831`): ``` $ YKD_SERIALISE_COMPILATION=1 gdb -ex 'r' -ex 'bt' --args ../src/lua -e"_U=true" ./all.lua ... ***** FILE 'main.lua'***** Program received signal SIGSEGV, Segmentation fault. core::sync::atomic::AtomicUsize::fetch_sub (self=<optimised out>) at /rustc/ef85656a10657ba5e4f7fe2931a4ca6293138d51/library/core/src/sync/atomic.rs:2575 2575 /rustc/ef85656a10657ba5e4f7fe2931a4ca6293138d51/library/core/src/sync/atomic.rs: No such file or directory. #0 core::sync::atomic::AtomicUsize::fetch_sub (self=<optimised out>) at /rustc/ef85656a10657ba5e4f7fe2931a4ca6293138d51/library/core/src/sync/atomic.rs:2575 #1 alloc::sync::{impl#33}::drop<lock_api::mutex::Mutex<parking_lot::raw_mutex::RawMutex, ykrt::location::HotLocation>, alloc::alloc::Global> (self=0x7fffffffb410) at /rustc/ef85656a10657ba5e4f7fe2931a4ca6293138d51/library/alloc/src/sync.rs:2370 #2 0x00007ffff7b0d4ab in core::ptr::drop_in_place<alloc::sync::Arc<lock_api::mutex::Mutex<parking_lot::raw_mutex::RawMutex, ykrt::location::HotLocation>, alloc::alloc::Global>> () at /rustc/ef85656a10657ba5e4f7fe2931a4ca6293138d51/library/core/src/ptr/mod.rs:497 #3 0x00007ffff7b0067e in core::mem::drop<alloc::sync::Arc<lock_api::mutex::Mutex<parking_lot::raw_mutex::RawMutex, ykrt::location::HotLocation>, alloc::alloc::Global>> (_x=...) at /rustc/ef85656a10657ba5e4f7fe2931a4ca6293138d51/library/core/src/mem/mod.rs:987 #4 0x00007ffff7b121f0 in ykrt::location::{impl#1}::drop (self=0x7fffffffb468) at ykrt/src/location.rs:197 #5 0x00007ffff7affa9b in core::ptr::drop_in_place<ykrt::location::Location> () at /rustc/ef85656a10657ba5e4f7fe2931a4ca6293138d51/library/core/src/ptr/mod.rs:497 #6 0x00007ffff7aff6bd in core::mem::drop<ykrt::location::Location> (_x=...) at /rustc/ef85656a10657ba5e4f7fe2931a4ca6293138d51/library/core/src/mem/mod.rs:987 #7 0x00007ffff7b004bd in ykcapi::yk_location_drop (loc=...) at ykcapi/src/lib.rs:90 #8 0x000000000088aa0e in free_loc (f=<optimised out>, i=<optimised out>, idx=<optimised out>) at lyk.c:66 #9 0x000000000088aba5 in yk_free_locactions (f=0x928cc0) at lyk.c:76 --Type <RET> for more, q to quit, c to continue without paging-- #10 0x0000000000807738 in luaF_freeproto (L=0x916e38, f=0x928cc0) at lfunc.c:276 #11 0x0000000000809fde in freeobj (L=0x916e38, o=0x928cc0) at lgc.c:767 #12 0x0000000000817145 in sweepgen (L=0x916e38, g=<optimised out>, p=<optimised out>, limit=<optimised out>, pfirstold1=<optimised out>) at lgc.c:1106 #13 0x0000000000816713 in youngcollection (L=0x916e38, g=0x916f00) at lgc.c:1239 #14 0x000000000081557d in genstep (L=0x916e38, g=0x916f00) at lgc.c:1434 #15 0x0000000000815044 in luaC_step (L=0x916e38) at lgc.c:1686 #16 0x00000000007e4447 in lua_pushstring (L=0x916e38, s=<optimised out>) at lapi.c:553 #17 0x000000000089e60c in findloader (L=0x916e38, name=0x928df8 "tracegc") at loadlib.c:641 #18 0x000000000089de0a in ll_require (L=0x916e38) at loadlib.c:666 #19 0x00000000007fda75 in precallC (L=0x916e38, func=<optimised out>, nresults=<optimised out>, f=0x89db80 <ll_require>) at ldo.c:506 #20 0x00000000007fe016 in luaD_precall (L=0x916e38, func=0x923780, nresults=1) at ldo.c:569 #21 0x0000000000883f68 in luaV_execute (L=0x916e38, ci=<optimised out>) at lvm.c:1655 #22 0x00000000007feb3b in ccall (L=0x916e38, func=<optimised out>, nResults=<optimised out>, inc=<optimised out>) at ldo.c:609 #23 0x00000000007fec61 in luaD_callnoyield (L=0x916e38, func=0x917730, nResults=-1) at ldo.c:627 #24 0x00000000007eaf03 in f_call (L=0x916e38, ud=<optimised out>) at lapi.c:1041 #25 0x00000000007f8be7 in luaD_rawrunprotected (L=0x916e38, f=0x7eae40 <f_call>, ud=0x7ffff2487308) at ldo.c:144 #26 0x0000000000801406 in luaD_pcall (L=0x916e38, func=0x7eae40 <f_call>, u=0x7ffff2487308, old_top=<optimised out>, ef=<optimised out>) at ldo.c:926 #27 0x00000000007ea9ec in lua_pcallk (L=0x916e38, nargs=<optimised out>, nresults=<optimised out>, errfunc=<optimised out>, ctx=<optimised out>, k=<optimised out>) at lapi.c:1067 #28 0x00000000007dc623 in docall (L=0x916e38, narg=0, nres=-1) at lua.c:160 #29 0x00000000007dbd24 in handle_script (L=0x916e38, argv=<optimised out>) at lua.c:255 #30 0x00000000007d9fe3 in pmain (L=0x916e38) at lua.c:634 #31 0x00000000007fda75 in precallC (L=0x916e38, func=<optimised out>, nresults=<optimised out>, f=0x7d97f0 <pmain>) at ldo.c:506 #32 0x00000000007fe0c8 in luaD_precall (L=0x916e38, func=0x9176f0, nresults=1) at ldo.c:572 #33 0x00000000007fea7f in ccall (L=0x916e38, func=0x9176f0, nResults=1, inc=<optimised out>) at ldo.c:607 #34 0x00000000007fec61 in luaD_callnoyield (L=0x916e38, func=0x9176f0, nResults=1) at ldo.c:627 #35 0x00000000007eaf03 in f_call (L=0x916e38, ud=<optimised out>) at lapi.c:1041 #36 0x00000000007f8be7 in luaD_rawrunprotected (L=0x916e38, f=0x7eae40 <f_call>, ud=0x7ffff2487058) at ldo.c:144 #37 0x0000000000801406 in luaD_pcall (L=0x916e38, func=0x7eae40 <f_call>, u=0x7ffff2487058, old_top=<optimised out>, ef=<optimised out>) at ldo.c:926 #38 0x00000000007ea9ec in lua_pcallk (L=0x916e38, nargs=<optimised out>, nresults=<optimised out>, errfunc=<optimised out>, ctx=<optimised out>, k=<optimised out>) at lapi.c:1067 #39 0x00000000007d94b0 in main (argc=<optimised out>, argv=<optimised out>) at lua.c:660 ``` That's cause we're freeing uninitialised yk locations. Co-authored-by: Pavel Durov <[email protected]>
The text was updated successfully, but these errors were encountered: