openresty / luajit2

OpenResty's Branch of LuaJIT 2
https://luajit.org/luajit.html
Other
1.24k stars 200 forks source link

This PR fixes s390x issues and enables CI #144

Closed velemas closed 2 years ago

velemas commented 2 years ago

This PR fixes issue https://github.com/openresty/luajit2/issues/136 and breakage introduced by commit 5980ef945c459625a21d8f397fb8a4cf043c1771 seen in https://github.com/kubernetes/ingress-nginx/issues/6504 on s390x.

Additionally implemented:

Signed-off-by: Artiom Vaskov artiom.vaskov@ibm.com

velemas commented 2 years ago

s390x build with Valgrind failed. Running Valgrind build locally with Valgrind 3.16 results only in 4 failed tests with the same error:

==900264== Process terminating with default action of signal 4 (SIGILL): dumping core
==900264==  Illegal opcode at address 0x1027EB0
==900264==    at 0x1027EB0: lj_vm_floor (in /usr/local/bin/luajit-2.1.0-beta3)
==900264==    by 0x1011A79: lua_pcall (lj_api.c:1145)
==900264==    by 0x1004BEF: docall (luajit.c:121)
==900264==    by 0x1005BF1: handle_script (luajit.c:292)
==900264==    by 0x1005BF1: pmain (luajit.c:553)
==900264==    by 0x1025861: lj_BC_FUNCC (in /usr/local/bin/luajit-2.1.0-beta3)
==900264==    by 0x1011ADB: lua_cpcall (lj_api.c:1173)
==900264==    by 0x100465F: main (luajit.c:582)

Disassemble of lj_vm_floor shows a legal DIDBR instruction at 0x1027EB0:

Dump of assembler code for function lj_vm_floor:
   0x0000000001027ea8 <+0>:     lghi    %r0,1
   0x0000000001027eac <+4>:     cdfbr   %f1,%r0
   0x0000000001027eb0 <+8>:     didbr   %f0,%f2,%f1,7
   0x0000000001027eb4 <+12>:    jnle    0x1027ebc <lj_vm_floor+20>
   0x0000000001027eb8 <+16>:    ldr     %f0,%f2
   0x0000000001027eba <+18>:    br      %r14
   0x0000000001027ebc <+20>:    stg     %r0,0

Running Valgrind in verbose mode and with --sigill-diagnostics=yes produces:

vex s390->IR: unimplemented insn: B35B 2701
==915074== valgrind: Unrecognised instruction at address 0x1027eb0.
==915074==    at 0x1027EB0: lj_vm_floor (in /usr/local/bin/luajit-2.1.0-beta3)
==915074==    by 0x1011A79: lua_pcall (lj_api.c:1145)
==915074==    by 0x1004BEF: docall (luajit.c:121)
==915074==    by 0x1005BF1: handle_script (luajit.c:292)
==915074==    by 0x1005BF1: pmain (luajit.c:553)
==915074==    by 0x1025861: lj_BC_FUNCC (in /usr/local/bin/luajit-2.1.0-beta3)
==915074==    by 0x1011ADB: lua_cpcall (lj_api.c:1173)
==915074==    by 0x100465F: main (luajit.c:582)
==915074== Your program just tried to execute an instruction that Valgrind
==915074== did not recognise.  There are two possible reasons for this.
==915074== 1. Your program has a bug and erroneously jumped to a non-code
==915074==    location.  If you are running Memcheck and you just saw a
==915074==    warning about a bad jump, it's probably your program's fault.
==915074== 2. The instruction is legitimate but Valgrind doesn't handle it,
==915074==    i.e. it's Valgrind's fault.  If you think this is the case or
==915074==    you are not sure, please let us know and we'll try to fix it.
==915074== Either way, Valgrind will now raise a SIGILL signal which will
==915074== probably kill your program.

So it looks like Valgrind build should be disabled for s390x for now.