Lua 5.5.1 (rc1) is now available for testing at
https://www.lua.org/work/lua-5.5.1-rc1.tar.gz
All feedback welcome. Thanks.
--lhf
Hello,
Lua 5.5.1-rc1 passes all LuaX tests but there are some undefined behaviours detected by UBSan.
E.g.:
make MYCFLAGS="-fsanitize=address -fsanitize=undefined"
MYLDFLAGS="-fsanitize=address -fsanitize=undefined"
src/lua -v
produces:
lua-5.5.1/src/lstate.c:352:14: runtime error: member access
within misaligned address 0x7d51507e0608 for type 'union GCUnion',
which requires 16 byte alignment
0x7d51507e0608: note: pointer points here
be be be be be be be be be be be be 08 08 01 00 be be be be be
be be be be be be be 80 00 7e 50
^
lua-5.5.1/src/lstate.c:201:3: runtime error: member access within
misaligned address 0x7d51507e0608 for type 'union GCUnion', which
requires 16 byte alignment
0x7d51507e0608: note: pointer points here
be be be be 00 00 00 00 00 00 00 00 08 08 01 00 be be be be 90
00 7e 50 11 7d 00 00 80 00 7e 50
^
Lua 5.5.1 Copyright (C) 1994-2026 Lua.org, PUC-Rio
lua-5.5.1/src/lgc.c:443:3: runtime error: member access within
misaligned address 0x7d51507e0608 for type 'union GCUnion', which
requires 16 byte alignment
0x7d51507e0608: note: pointer points here
be be be be 00 00 00 00 00 00 00 00 08 08 01 00 be be be be c0
00 7e 50 11 7d 00 00 80 00 7e 50
^
lua-5.5.1/src/lgc.c:140:29: runtime error: member access within
misaligned address 0x7d51507e0608 for type 'union GCUnion', which
requires 16 byte alignment
0x7d51507e0608: note: pointer points here
be be be be 00 00 00 00 00 00 00 00 08 08 01 00 be be be be c0
00 7e 50 11 7d 00 00 80 00 7e 50
^
lua-5.5.1/src/lgc.c:168:30: runtime error: member access within
misaligned address 0x7d51507e0608 for type 'union GCUnion', which
requires 16 byte alignment
0x7d51507e0608: note: pointer points here
be be be be 00 00 00 00 00 00 00 00 08 08 01 00 be be be be c0
00 7e 50 11 7d 00 00 80 00 7e 50
^
lua-5.5.1/src/lgc.c:367:7: runtime error: member access within
misaligned address 0x7d51507e0608 for type 'union GCUnion', which
requires 16 byte alignment
0x7d51507e0608: note: pointer points here
be be be be 00 00 00 00 00 00 00 00 08 08 01 00 be be be be c0
00 7e 50 11 7d 00 00 80 00 7e 50
^
lua-5.5.1/src/lgc.c:737:48: runtime error: member access within
misaligned address 0x7d51507e0608 for type 'union GCUnion', which
requires 16 byte alignment
0x7d51507e0608: note: pointer points here
be be be be 00 00 00 00 00 00 00 00 08 20 01 00 be be be be c0
00 7e 50 11 7d 00 00 80 00 7e 50
^
lua-5.5.1/src/lgc.c:1148:20: runtime error: member access within
misaligned address 0x7d51507e0608 for type 'union GCUnion', which
requires 16 byte alignment
0x7d51507e0608: note: pointer points here
be be be be 00 00 00 00 00 00 00 00 08 24 01 00 be be be be c0
00 7e 50 11 7d 00 00 80 00 7e 50
^
lua-5.5.1/src/lgc.c:1149:9: runtime error: member access within
misaligned address 0x7d51507e0608 for type 'union GCUnion', which
requires 16 byte alignment
0x7d51507e0608: note: pointer points here
be be be be 00 00 00 00 00 00 00 00 08 24 01 00 be be be be c0
00 7e 50 11 7d 00 00 80 00 7e 50
^
lua-5.5.1/src/lgc.c:1536:3: runtime error: member access within
misaligned address 0x7d51507e0608 for type 'union GCUnion', which
requires 16 byte alignment
0x7d51507e0608: note: pointer points here
be be be be 00 00 00 00 00 00 00 00 08 04 01 00 be be be be 90
00 7e 50 11 7d 00 00 80 00 7e 50
^
Regards,
Christophe.
> lua-5.5.1/src/lstate.c:352:14: runtime error: member access within
> misaligned address 0x7d51507e0608 for type 'union GCUnion', which requires
> 16 byte alignment
> 0x7d51507e0608: note: pointer points here
> be be be be be be be be be be be be 08 08 01 00 be be be be be be be be
> be be be be 80 00 7e 50
> ^
> [...]
I believe gcc is being overzealous here and possibly breaking the C
standard. The standard says this:
"A pointer to a union object, suitably converted, points to each of
its members [...], and vice versa."
So, if a member is an int, it should be valid to convert a pointer to
int (with its 4-byte alignment) to a pointer to the union, and then
convert it back to a pointer to int.