[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LPeg bug with nil captures
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 21 May 2015 13:02:13 -0300
> Hello,
>
> This is definitely a bad day for LPeg :)
>
> One of the fixes of LPeg 0.12.1 was related to nil captures, the fix
> was to set an empty ktable as uservalue for Lua 5.2+. However, the
> following code still have issues with LPeg 0.12.2:
>
> Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> > L=require 'lpeg'
> > =L.version()
> 0.12.2
> > =(L.P"aaa" * L.Cc(nil)):match"aaa"
> lua: lapi.c:653: lua_rawgeti: Assertion `(((((t))->tt_) == (((5) | (1
> << 6))))) && "table expected"' failed.
>
> This is the case only when the Lua VM is compiled with
> -DLUA_USE_APICHECK, otherwise the behavior is not defined (sometimes
> segfaults).
>
> This is because the 'L.Cc(nil)' pattern do have an empty ktable, but
> when merged with 'L.P"aaa"', the joinktables considers that neither of
> source patterns have a ktable and keeps the nil uservalue of resulting
> pattern. When matching is attempted, LPeg attempts to push the capture
> by calling lua_rawgeti on that nil uservalue.
>
> This issue does not occur with Lua 5.1 as all userdata have a table as
> fenv.
That one I expect to be easy to fix :-) (Thanks for the report.)
-- Roberto