Skip to content
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

Misleading assertion in asm_fload() for mips. #1043

Closed
Buristan opened this issue Aug 2, 2023 · 1 comment
Closed

Misleading assertion in asm_fload() for mips. #1043

Buristan opened this issue Aug 2, 2023 · 1 comment

Comments

@Buristan
Copy link

Buristan commented Aug 2, 2023

This is about the following assertion:

lj_assertA(!irt_isfp(ir->t), "bad FP FLOAD");

After 786dbb2 it is possible to use FLOAD for fields load from GG_State.
In particular, it is used for load of LJ_KSIMD_ABS (num FLOAD nil #404). This IR has number type, so this leads to the assertion failure (-O0 is used for more simple repro):

LUA_PATH="src/?.lua;;" LD_LIBRARY_PATH="/usr/lib/gcc/mips64el-unknown-linux-gnu/13/" qemu-mips64el -L /usr/mips64el-unknown-linux-gnu/ src/luajit -jdump=i -Ohotloop=1 -O0 -e '
local t = {nil, nil,nil,nil}
for i = 1, 4 do
  t[i] = math.abs(i - 10)
end
for i = 1, 4 do
  print(t[i])
end
'
---- TRACE 1 start (command line):3
LuaJIT ASSERT lj_asm_mips.h:1341: asm_fload: bad FP FLOAD
Aborted (core dumped)

Should the assertion be inside else branch too, like the following?

diff --git a/src/lj_asm_mips.h b/src/lj_asm_mips.h
index e9cce916..8824081e 100644
--- a/src/lj_asm_mips.h
+++ b/src/lj_asm_mips.h
@@ -1337,8 +1337,8 @@ static void asm_fload(ASMState *as, IRIns *ir)
       }
     }
     ofs = field_ofs[ir->op2];
+    lj_assertA(!irt_isfp(ir->t), "bad FP FLOAD");
   }
-  lj_assertA(!irt_isfp(ir->t), "bad FP FLOAD");
   emit_tsi(as, mi, dest, idx, ofs);
 }
MikePall pushed a commit that referenced this issue Aug 13, 2023
Reported by Sergey Kaplun. #1043
@MikePall
Copy link
Member

Fixed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants