[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Segfault when parsing 4GB file.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Sat, 31 Jan 2015 19:01:01 -0200
> On Sat, Jan 31, 2015 at 2:45 AM, Soni L. <fakedme@gmail.com> wrote:
>
> > So I gave Lua 5.2.3 (on archlinux x86_64) a 4GB file of " \n" (where \n
> > is an actual newline). It segfaulted. I expected it to error with "chunk
> > has too many lines". (Also, why are the errors all lowercase? ("chunk has
> > too many lines" instead of "Chunk has too many lines"))
> >
>
> For me lua5.1.5, lua5.2.1 and luajit 2.0.3 write "chunk has too many
> lines". Debian wheezy amd64.
This is a bug in the error report. The error message would be more like
"chunk has too many lines near <token>", but as Lua did not read any
token yet, it uses an unitialized variable with the code of the last
token read. Because the error is around an unitialized variable, it
may not be reproductible.
In Lua 5.3 this has already been fixed:
@@ -156,12 +156,13 @@
if (currIsNewline(ls) && ls->current != old)
next(ls); /* skip '\n\r' or '\r\n' */
if (++ls->linenumber >= MAX_INT)
- luaX_syntaxerror(ls, "chunk has too many lines");
+ lexerror(ls, "chunk has too many lines", 0);
}
void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source,
int firstchar) {
+ ls->t.token = 0;
ls->decpoint = '.';
ls->L = L;
ls->current = firstchar;
Maybe the same fix can be used in Lua 5.2 (probably in different lines).
-- Roberto