lua-users home
lua-l archive

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


I seem to have discovered an issue within lua, when LUA_NUMBER is defined as a float in luaconf.h. 

Specifically, the standard library implementation of math_modf which is used by lua ends up passing a pointer to a float to the standard library modf function. However, this function expects a pointer to double, and because of this, ends up corrupting the stack (I assume by writing an 8 byte value to a 4 byte location). 

I don't know how supported those default libs are, or in the situation of changing luaconf to use a different precision, but I thought I'd throw it out there. 

I managed to repro the issue with lua 5.2.3 from source, in Visual Studio 2010 by simply compiling the source with LUA_NUMBER redefined and calling math.modf() from the interpreter command line with any value. 

Honestly the fix is pretty easy and straightforward, but it's an interesting case where being able to redefine the basic type actually breaks functionality. 

Charles Randall
@charlesrandall