[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: dofile("luac.out") segfaults
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 11 Apr 2001 09:59:33 -0300
> About the bug: ldo.c:protectedparser _does_ calls the GC (early, just
> before compilation/undumping). So the assumption in ldo.c:parse_file
> is wrong.
> --- ldo.c Wed Apr 11 02:09:10 2001
> +++ ldo.c Wed Apr 11 02:09:34 2001
> @@ -275,9 +275,9 @@
> lua_pushstring(L, (filename == NULL) ? "(stdin)" : filename);
> lua_concat(L, 2);
> filename = lua_tostring(L, -1); /* filename = '@'..filename */
> - lua_pop(L, 1); /* OK: there is no GC during parser */
> luaZ_Fopen(&z, f, filename);
> status = protectedparser(L, &z, bin);
> + lua_pop(L, 1); /* filename */
> if (f != stdin)
> fclose(f);
> return status;
Actually, the assumption is wrong; but so is the fix. `protectedparser'
leaves the compiled chunk on the stack, so pop will remove it, instead of
removing the filename. (On the other hand, `protectedparser' will not leave
a function on the stack in case of errors, so «lua_remove(L, -2)» don't
work, either.)
-- Roberto