[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lua-5.1 restorestack memory handling bug
- From: Marko Lindqvist <cazfi74@...>
- Date: Tue, 7 Feb 2012 09:57:54 +0200
Freeciv ( http://www.freeciv.org/ ) source tree includes copy of
lua-5.1. We got a bug report about build failure, and this might be a
real bug (at least on some platforms and compiler options)
I managed to reproduce myself building with clang, and I think this
error message describes problem best:
dependencies/lua-5.1/src/ldebug.c:620:21: error: cast
from 'char ' to 'TValue ' (aka 'struct lua_TValue *') increases required
alignment from 1 to 8 [-Werror,-Wcast-align]
StkId errfunc = restorestack(L, L->errfunc);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
../../../../../src.patched/dependencies/lua-5.1/src/ldebug.c:21:
../../../../../src.patched/dependencies/lua-5.1/src/ldo.h:25:28: note:
instantiated from:
#define restorestack(L,n) ((TValue )((char )L->stack + (n)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
So, "L->stack + (n)" is calculated as char (1 byte space reserved),
but then cast to pointer (8 bytes). In theory that pointer now has 7*8
of its bits in undefined state.
Original bug report: http://gna.org/bugs/?18481
- ML