9

I really hope there is some help to get on this subject. Has anyone ever used lua in an application that needs to have both 32-bit and 64-bit support? We are currently transitioning to 64-bit but are having trouble with client compiled lua scripts that we can't recompile ourselves using the 64-bit version. So in effect we need to be able to load bytecode files compiled using 32-bit lua in a 64-bit application. When we try to do so we receive an error message:

virtual machine mismatch in test.bin.lua: size of size_t is 8 but read 4

Well of course this is a clear 64bit transitioning problem. The hard thing is just to figure out what to do about it without the ability to recompile the binaries.

Thanks

Tuminoid
  • 9,445
  • 7
  • 36
  • 51
thehan
  • 301
  • 1
  • 3
  • 9
  • 2
    note that loading bytecode is discouraged. safer and more portable is to load source code. – Javier Sep 23 '10 at 21:19

2 Answers2

3

It's not hard to adapt lundump.c to read 32-bit bytecode files. I've posted a roadmap for this in the Lua mailing list. If you have problems, please send me email.

lhf
  • 70,581
  • 9
  • 108
  • 149
  • I'm interested in this subject. Do you have a to your mailing list post? – Andreas Apr 06 '16 at 13:58
  • Thanks. It was actually really trivial since I just had to modify `lundump.c` to be able to deal with `size_t` sizes of 4 bytes *and* 8 bytes. After this modification the 32-bit versions of my program are now magically able to run bytecode produced by the 64-bit version and vice versa. Of course it won't work on 32-bit if there is really a string with more than 2^32 bytes of data but that's rather unlikely I guess :) Another thing I had to change was the `Instruction` typedef from `unsigned long` to `unsigned int` because instructions should be 32-bit. Note that I'm still on Lua 5.0.2. – Andreas Apr 06 '16 at 15:03
  • @Andreas, thanks for the feedback. Consider updating to Lua 5.0.3, which is the last release of Lua 5.0. – lhf Apr 06 '16 at 16:10
1

You could try LuaDec: "LuaDec is a decompiler for the Lua language." I don't know much about it, and the website states that it targets Lua 5.0.2. So, it may not work out of the box, but it's better than starting from scratch.

Judge Maygarden
  • 26,961
  • 9
  • 82
  • 99