ARM modulo operator corrupted result?

  • From: Ben Garney <ben@xxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 29 Dec 2015 12:46:08 -0800

Hello!

We're experiencing what seems to be buggy behavior with the modulo operator
(%) on ARM devices.

We made a small test case [1] that returns the expected results on Windows
8.1 and OSX 10.9.5 [2], but on ARM devices (observed on Nexus 5 w/ Android
6.0.1 and an iPod Touch 5th Gen on iOS 7.1.2) can give very wrong results
[3].

We are only seeing the buggy behavior in LuaJIT 2.1.0-beta1 and up (still
present in 0345f361531c756367257eb2f147c707e1710218), whether the JIT
engine is enabled or disabled and only on ARM devices (32/64bit x86 Win/OSX
are fine). Lua classic and LuaJIT 2.0.4 work fine on x86 and ARM.

We also dumped the Lua stack to try to spot anything that might be going
wrong but see little difference (other than bad results). The results don't
seem entirely consistent and can change due to undetermined usage patterns
and surrounding Lua code, however they do seem to be consistent from run to
run of the same build.

We have tested with the built-in lua allocator as well as our own debug
allocators which check for buffer overrun. We have not found any evidence
of memory corruption.

We are close to shipping 64 bit versions of the Loom SDK and this is one of
the last major issues on our plate... Any insights and ideas would be
appreciated, thanks!

Thanks,
Ben

[1] https://gist.github.com/SmilyOrg/5e7e48d0599660b50565

[2] https://gist.github.com/SmilyOrg/905767d0e79ba9b3aca0

[3] https://gist.github.com/SmilyOrg/6ec020625fc1217f0490

Other related posts: