This lua_assert: https://github.com/lua/lua/blob/6bc0f13505bf5d4f613d725fe008c79e72f83ddf/lstring.c#L206 Should be two lines higher, before the call to luaS_hash, which dereferences str unconditionally.