[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Looking for some help debugging a weird crash in Lua
- From: Robert Burke <sharpobject@...>
- Date: Wed, 10 Mar 2021 10:16:39 +0900
On Wed, Mar 10, 2021 at 9:54 AM Chris Jones <cmsj@tenshu.net> wrote:
> n = (*f)(L);
>
> and f seemingly points to g_read since that is next in the backtrace, except this is where I get confused - the declaration of g_read() is:
>
> static int g_read (lua_State *L, FILE *f, int first);
>
> so the second two parameters aren't being passed any values. I believe this is undefined behaviour in C, but the "garbage pointer 0x2" suggests to me that clang is passing them as NULL or zero or something along those lines.
I suspect that f actually points to io_read or f_read:
static int io_read (lua_State *L) {
return g_read(L, getiofile(L, IO_INPUT), 1);
}
static int f_read (lua_State *L) {
return g_read(L, tofile(L), 2);
}
and that the compiler has replaced the tail call with a jump, so that
the function pointed to by f is absent from your stack trace.