Hello,
I am getting assert fails with luajit-2.1.0 beta3(release version) in not
GC64 mode:
Program terminated with signal SIGABRT, Aborted.
[25/7117]
#0 0x0000003fb10328a5 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x0000003fb10328a5 in raise () from /lib64/libc.so.6
#1 0x0000003fb1034085 in abort () from /lib64/libc.so.6
#2 0x0000003fb102ba1e in __assert_fail_base () from /lib64/libc.so.6
#3 0x0000003fb102bae0 in __assert_fail () from /lib64/libc.so.6
#4 0x00000000006aaebd in ptr2addr (p=<optimized out>) at lj_emit_x86.h:95
#5 0x00000000006aba7f in emit_rma (as=<optimized out>, xo=XO_MOVSD,
rr=23, addr=<optimized out>) at lj_emit_x86.h:353
#6 0x00000000006abca7 in ra_rematk (as=<optimized out>,
ref=<optimized out>) at lj_asm.c:343
#7 0x00000000006b5882 in ra_evictk (as=0x7fffad4f60a0) at lj_asm.c:513
#8 lj_asm_trace (J=0x40c5a558, T=0x40c5a558) at lj_asm.c:2363
#9 0x000000000068712d in trace_state (L=0x8000fbe0, dummy=<optimized
out>, ud=0x40c5a558) at lj_trace.c:691
#10 0x000000000069139a in lj_vm_cpcall () at buildvm_x86.dasc:1181
#11 0x000000000068626d in lj_trace_ins (J=0x40c5a558, pc=<optimized
out>) at lj_trace.c:723
#12 0x0000000000676653 in lj_dispatch_call (L=0x8000fbe0,
pc=0x40c5a4b0) at lj_dispatch.c:493
#13 0x0000000000692a0e in lj_vm_hotcall () at buildvm_x86.dasc:2386
#14 0x000000000054a333 in ngx_http_lua_run_thread (L=0x40c5a378,
r=0x7fcf2cdf3060, ctx=0x7fcf27a96020, nrets=0) at
mod_lua/src/ngx_http_lua_util.c:1015
#15 0x000000000054c5b9 in ngx_http_lua_rewrite_by_chunk (L=0x40c5a378,
r=0x7fcf2cdf3060) at mod_lua/src/ngx_http_lua_rewriteby.c:331
#16 0x000000000054c7b4 in ngx_http_lua_rewrite_handler_file
(r=0x7fcf2cdf3060) at mod_lua/src/ngx_http_lua_rewriteby.c:228
#17 0x000000000054caf3 in ngx_http_lua_rewrite_handler
(r=0x7fcf2cdf3060) at mod_lua/src/ngx_http_lua_rewriteby.c:162
#18 0x000000000049c3a4 in ngx_http_core_rewrite_phase
(r=0x7fcf2cdf3060, ph=<optimized out>) at
src/http/ngx_http_core_module.c:1089
#19 0x000000000049892d in ngx_http_core_run_phases (r=0x7fcf2cdf3060)
at src/http/ngx_http_core_module.c:1030
#20 0x00000000004a6f3e in ngx_http_process_request (r=0x7fcf2cdf3060)
at src/http/ngx_http_request.c:3755
#21 0x00000000004a7e3e in ngx_http_process_request_line
(rev=0x7fcf200a3978) at src/http/ngx_http_request.c:2753
#22 0x00000000004a35fa in ngx_http_protocol_detect
(rev=0x7fcf200a3978) at src/http/ngx_http_request.c:776
#23 0x0000000000487e5f in ngx_epoll_process_events (cycle=<optimized
out>, timer=<optimized out>, flags=<optimized out>) at
src/event/modules/ngx_epoll_module.c:683
#24 0x000000000047dab9 in ngx_process_events_and_timers
(cycle=0x7fcf2affb060) at src/event/ngx_event.c:291
#25 0x0000000000486828 in ngx_worker_process_cycle
(cycle=0x7fcf2affb060, data=<optimized out>) at
src/os/unix/ngx_process_cycle.c:927
#26 0x0000000000483707 in ngx_spawn_process (cycle=0x7fcf2affb060,
proc=0x486710 <ngx_worker_process_cycle>, data=0x3, name=0x8b94b7
"worker process", respawn=-4) at src/os/unix/ngx_process.c:191
#27 0x0000000000485b3c in ngx_start_worker_processes
(cycle=0x7fcf2affb060, n=16, type=-4) at
src/os/unix/ngx_process_cycle.c:409
#28 0x0000000000486eef in ngx_master_process_cycle
(cycle=0x7fcf2affb060) at src/os/unix/ngx_process_cycle.c:272
#29 0x00000000004618d7 in main (argc=<optimized out>, argv=<optimized
out>) at src/core/nginx.c:493
(gdb) f 4
#4 0x00000000006aaebd in ptr2addr (p=<optimized out>) at lj_emit_x86.h:95
95 lua_assert((uintptr_t)p < (uintptr_t)0x80000000);
(gdb) f 5
#5 0x00000000006aba7f in emit_rma (as=<optimized out>, xo=XO_MOVSD,
rr=23, addr=<optimized out>) at lj_emit_x86.h:353
353 *(int32_t *)(p-4) = ptr2addr(addr);
(gdb) l
348 emit_loadu64(as, rr, (uintptr_t)addr);
349 } else
350 #endif
351 {
352 MCode *p = as->mcp;
353 *(int32_t *)(p-4) = ptr2addr(addr);
354 #if LJ_64
355 p[-5] = MODRM(XM_SCALE1, RID_ESP, RID_EBP);
356 as->mcp = emit_opm(xo, XM_OFS0, rr, RID_ESP, p, -5);
357 #else
(gdb)
358 as->mcp = emit_opm(xo, XM_OFS0, rr, RID_EBP, p, -4);
359 #endif
360 }
361 }
362
363 /* Load 64 bit IR constant into register. */
364 static void emit_loadk64(ASMState *as, Reg r, IRIns *ir)
365 {
366 Reg r64;
367 x86Op xo;
Related to this issuse: ptr2addr in GC64 mode
<https://www.freelists.org/post/luajit/ptr2addr-in-GC64-mode>
*Mike Pall said "Fixed in the git v2.1 branch."*
I tried to find the fix commits, and found two as follows:
commit 7e662e4f87134f1e84f7bea80933e033c5bf53a3
Author: Mike Pall <mike>
Date: Wed Jul 26 09:52:53 2017 +0200
x64/LJ_GC64: Fix emit_rma().
diff --git a/src/lj_emit_x86.h b/src/lj_emit_x86.h
index 5207f9d..5b139bd 100644
--- a/src/lj_emit_x86.h
+++ b/src/lj_emit_x86.h
@@ -343,9 +343,27 @@ static void emit_rma(ASMState *as, x86Op xo, Reg
rr, const void *addr)
emit_rmro(as, xo, rr, RID_DISPATCH, (int32_t)dispofs(as, addr));
} else if (checki32(mcpofs(as, addr)) && checki32(mctopofs(as, addr))) {
emit_rmro(as, xo, rr, RID_RIP, (int32_t)mcpofs(as, addr));
- } else if (!checki32((intptr_t)addr) && (xo == XO_MOV || xo == XO_MOVSD)) {
- emit_rmro(as, xo, rr, rr, 0);
- emit_loadu64(as, rr, (uintptr_t)addr);
+ } else if (!checki32((intptr_t)addr)) {
+ Reg ra = (rr & 15);
+ if (xo != XO_MOV) {
+ /* We can't allocate a register here. Use and restore DISPATCH. Ugly. */
+ uint64_t dispaddr = (uintptr_t)J2GG(as->J)->dispatch;
+ uint8_t i8 = xo == XO_GROUP3b ? *as->mcp++ : 0;
+ ra = RID_DISPATCH;
+ if (checku32(dispaddr)) {
+ emit_loadi(as, ra, (int32_t)dispaddr);
+ } else { /* Full-size 64 bit load. */
+ MCode *p = as->mcp;
+ *(uint64_t *)(p-8) = dispaddr;
+ p[-9] = (MCode)(XI_MOVri+(ra&7));
+ p[-10] = 0x48 + ((ra>>3)&1);
+ p -= 10;
+ as->mcp = p;
+ }
+ if (xo == XO_GROUP3b) emit_i8(as, i8);
+ }
+ emit_rmro(as, xo, rr, ra, 0);
+ emit_loadu64(as, ra, (uintptr_t)addr);
} else
#endif
{
commit b03a56f28ec360bbcf43091afd0607890a4a33c7
Author: Mike Pall <mike>
Date: Mon Jan 29 12:47:08 2018 +0100
FFI: Don't assert on #1LL (5.2 compatibility mode only).
Reported by Denis Golovan.
diff --git a/src/lib_ffi.c b/src/lib_ffi.c
index f2f2ede..83483d9 100644
--- a/src/lib_ffi.c
+++ b/src/lib_ffi.c
@@ -193,7 +193,7 @@ LJLIB_CF(ffi_meta___eq)
LJLIB_REC(cdata_arith MM_eq)
LJLIB_CF(ffi_meta___len) LJLIB_REC(cdata_arith MM_len)
{
- return ffi_arith(L);
+ return lj_carith_len(L);
}
LJLIB_CF(ffi_meta___lt) LJLIB_REC(cdata_arith MM_lt)
diff --git a/src/lj_carith.c b/src/lj_carith.c
index 6224dee..c34596c 100644
--- a/src/lj_carith.c
+++ b/src/lj_carith.c
@@ -272,6 +272,15 @@ int lj_carith_op(lua_State *L, MMS mm)
return lj_carith_meta(L, cts, &ca, mm);
}
+/* No built-in functionality for length of cdata. */
+int lj_carith_len(lua_State *L)
+{
+ CTState *cts = ctype_cts(L);
+ CDArith ca;
+ carith_checkarg(L, cts, &ca);
+ return lj_carith_meta(L, cts, &ca, MM_len);
+}
+
/* -- 64 bit integer arithmetic helpers ----------------------------------- */
#if LJ_32 && LJ_HASJIT
diff --git a/src/lj_carith.h b/src/lj_carith.h
index 3c15591..82fc824 100644
--- a/src/lj_carith.h
+++ b/src/lj_carith.h
@@ -11,6 +11,7 @@
#if LJ_HASFFI
LJ_FUNC int lj_carith_op(lua_State *L, MMS mm);
+LJ_FUNC int lj_carith_len(lua_State *L);
#if LJ_32 && LJ_HASJIT
LJ_FUNC int64_t lj_carith_mul64(int64_t x, int64_t k);
I compiled luajit like
# build and install lua
cd luajit
cd src
touch buildvm_*.h
cd ..
make -j CCDEBUG=-g XCFLAGS="-DLUA_USE_ASSERT -g"
make install PREFIX=%{buildroot}/luajit
export LUAJIT_LIB=%{buildroot}/luajit/lib
export LUAJIT_INC=%{buildroot}/luajit/include/luajit-2.1
Could @Mike Pall or @anyone else help answer, thks.