lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

>>>>> "Albert" == Albert Chan <> writes:

 >> Here is a small testcase (note that shortening the string eliminates the
 >> error):
 >> local lpeg = require 'lpeg'
 >> local P,Cs,Cmt = lpeg.P, lpeg.Cs, lpeg.Cmt
 >> local pat1 = P"a" / "b" + Cmt(P"c", function(_,p) return p,"d" end) + P(1)
 >> local pat = Cs(pat1^1)
 >> print(pat:match("abcdabcdabcdabcdabcdabcdabcdabc"))'

 Albert> What is above test code supposed to show ?
 Albert> I tried it on lpeg 1.0.1 without problem ...

With what output? on what platform? have you modified INITCAPSIZE?

When I run it (barring the stray ' at the end) I get the error "not
enough memory for buffer allocation" (because it's trying to allocate
nearly 2^64 bytes due to a bogus pointer value).

 Albert> OTTH, if string is longer than ('abcd'):rep(5510), it did
 Albert> *crash* Your 1 char patch, (n + 2) to (n + 1) seems to fix it.

The bug does depend on the state of newly-allocated memory (the contents
of a lua full userdata) so it may not be entirely predictable.