[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [LPeg] intermittent stack exhaustion
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 12 Sep 2016 15:25:25 -0300
> I also reduced the test case further.
>
>
> #!/usr/bin/env lua
> lpeg = require "lpeg"
>
> p = lpeg.P{
> "Line";
> P = lpeg.P"a",
> Q = lpeg.V"P",
> Line = lpeg.P"x" * lpeg.C(lpeg.V"P"),
> }
>
> p:ptree()
> p:match("xx")
>
> [...]
>
> I think the rule ordering is different because of string (key) hash
> randomization.
We can simplify a little more that grammar, using numeric indices:
p = lpeg.P{
(lpeg.P"x" * lpeg.C(1-lpeg.V(2))),
lpeg.P"a",
lpeg.V(2),
}
The use of numeric indices avoids the string hash randomization; as
a result, at least in my machine, we get a consistent seg. fault in
every run.
-- Roberto