ASan also reproduces and confirms this issue (and apologies for any
formatting issues):
└> clang -fsanitize=address -g -fno-omit-frame-pointer -I. -O2 test.c
liblua.a -lm
└> ./a.out
=================================================================
==11287==ERROR: AddressSanitizer: global-buffer-overflow on address
0xb0e37d0fe3ee at pc 0xb0e37cfa9514 bp 0xffffcdc30ba0 sp 0xffffcdc30390
READ of size 1 at 0xb0e37d0fe3ee thread T0
#0 0xb0e37cfa9510 in strchr (lua/a.out+0x59510) (BuildId:
f0de703ce44ff651f9cc906f255d8322f8543c58)
#1 0xb0e37d09f638 in luaO_pushvfstring lua/lobject.c:600:15
#2 0xb0e37d07cf04 in lua_pushfstring lua/lapi.c:602:3
#3 0xb0e37d078010 in main lua/test.c:8:5
#4 0xf7c3f9e02f18 in __libc_start_call_main
csu/../sysdeps/nptl/libc_start_call_main.h:59:16
#5 0xf7c3f9e03058 in __libc_start_main csu/../csu/libc-start.c:360:3
#6 0xb0e37cf8d0ec in _start (lua/a.out+0x3d0ec) (BuildId:
f0de703ce44ff651f9cc906f255d8322f8543c58)
0xb0e37d0fe3ee is located 18 bytes before global variable '.str.1'
defined in 'lua/test.c:10' (0xb0e37d0fe400) of size 9
'.str.1' is ascii string 'len: %d
'
0xb0e37d0fe3ee is located 0 bytes after global variable '.str' defined
in 'lua/test.c:8' (0xb0e37d0fe3e0) of size 14
'.str' is ascii string 'hello %d end%'
SUMMARY: AddressSanitizer: global-buffer-overflow (lua/a.out+0x59510)
(BuildId: f0de703ce44ff651f9cc906f255d8322f8543c58) in strchr