Issue: When using set table value multitimes with some specified order, ArrayIndexOutOfBoundsException will be thrown from LuaTable rehash method. Occurs every time by using the test case.
Luaj Version: luaj jse 3.0.1
JRE Version: Java SE 7 (1.7.0_51)
Test Case:
Globals globals = JsePlatform.standardGlobals();
LuaValue chunk = globals.load(""
+ " t = {[4] = true, [5] = true, [6] = true, [3] = true}\n"
+ " t[3] = nil\n"
+ " t[2] = true\n"
+ " t[1] = true\n");
chunk.call();
Exception Stacktrace:
Exception in thread "main" org.luaj.vm2.LuaError: t = {[4] = true, [5] = true, [6] = true, [3] = true}
t[3] = nil
t[2] = true
t[1] = true
:4 vm error: java.lang.ArrayIndexOutOfBoundsException: 0
at org.luaj.vm2.LuaClosure.execute(LuaClosure.java:504)
at org.luaj.vm2.LuaClosure.call(LuaClosure.java:133)
at LuaJTest.main(LuaJTest.java:41)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.luaj.vm2.LuaTable.rehash(LuaTable.java:719)
at org.luaj.vm2.LuaTable.hashset(LuaTable.java:472)
at org.luaj.vm2.LuaTable.rawset(LuaTable.java:283)
at org.luaj.vm2.LuaTable.set(LuaTable.java:272)
at org.luaj.vm2.LuaClosure.execute(LuaClosure.java:250)
... 2 more
patch: ignore DeadSlot copy
Last edit: Leijing Yang 2015-12-17