lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Bogdan Marinescu wrote:

    I'm going to put a bet on a compiled code issue with the
    compiler optimizing a copy or move incorrectly. Probably
    in the memcpy() or memmove() operation.

(*many printfs later...*)

Well I'll be. You are officially my new mentor :) You are right, "memcpy" is broken in their library. Probably they try to do memcpy on words instead of bytes to optimize speed, and they ignore alignment. So the memcpy in newlstr (lstring.c) triggered an aligment exception (I don't have any way to actually verify this, but now it's my time to bet that this is the problem, since one of its arguments is not aligned).
Thank you all for your help, and Ralph, very good call!

It's really just a good/lucky guess based on past experience.

To verify this, just take Lua out of the equation and use the
printf() to supply more information.

Do a memmove() or memcpy() and force the operands to be 32, 16, and
8 bit aligned, and see what happens when you have a misaligned
value being copied.

Now if only I could find a company that needs this kind of experience
I'd be happy :-)