Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with lpeg version 0.11-2 #8

Closed
cyfdecyf opened this issue Apr 18, 2013 · 13 comments
Closed

Not compatible with lpeg version 0.11-2 #8

cyfdecyf opened this issue Apr 18, 2013 · 13 comments

Comments

@cyfdecyf
Copy link

I installed lunamark (version 0.3-1) using luarocks on OS X, which installs lpeg version 0.11-2 to solve dependency. When run lunamark, I got the following error:

/usr/local/opt/lua/bin/lua: ...usr/local/share/lua/5.1/lunamark/reader/markdown.lua:122: pattern too large
stack traceback:
        [C]: in function 'lpegmatch'
        ...usr/local/share/lua/5.1/lunamark/reader/markdown.lua:122: in function 'parse_blocks'
        ...usr/local/share/lua/5.1/lunamark/reader/markdown.lua:1001: in function 'parse'
        ...local/lib/luarocks/rocks/lunamark/0.3-1/bin/lunamark:425: in main chunk
        [C]: ?

I manually installed lpeg version 0.10-2 and then lunamark works.

@craigbarnes
Copy link

This should be fixed in lpeg 0.12.

From the lpeg HISTORY file:

Changes from version 0.11 to 0.12

  • no "unsigned short" limit for pattern sizes

@andresy
Copy link

andresy commented Sep 17, 2013

I am afraid it is not compatible with lpeg 0.12 either :(
A simple:
writer = lunamark.writer.html.new()

fails with:

loop body may accept empty string
stack traceback:
[C]: at 0x0cac8640
[C]: in function 'match'
.../share/lua/re.lua:208: in function 'new'
.../share/lua/cosmo/grammar.lua:166: in main chunk
[C]: in function 'require'
.../share/lua/cosmo.lua:3: in main chunk
[C]: in function 'require'
.../share/lua/lunamark/util.lua:7: in main chunk
[C]: in function 'require'

@petsagouris
Copy link

I believe that this was an error with cosmo and was fixed with this issue mascarenhas/cosmo#6

@grrrwaaa
Copy link

I still have the same issue.

sudo luarocks install lpeg
Installing http://www.luarocks.org/repositories/rocks/lpeg-0.12-1.src.rock... etc.
sudo luarocks install cosmo
Installing http://www.luarocks.org/repositories/rocks/cosmo-13.01.30-1.src.rock... etc.
sudo luarocks install lunamark
Installing http://www.luarocks.org/repositories/rocks/lunamark-0.3-1.src.rock... etc.

luajit: loop body may accept empty string
stack traceback:
[C]: ?
[C]: in function 'match'
/usr/local/share/lua/5.1/re.lua:208: in function 'new'
/usr/local/share/lua/5.1/cosmo/grammar.lua:166: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/cosmo.lua:3: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/lunamark/util.lua:7: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/lunamark/writer/generic.lua:26: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/lunamark/writer/xml.lua:10: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/lunamark/writer/html.lua:9: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/lunamark/writer.lua:15: in function '__index'
./modules/md.lua:16: in function 'md'
./make.lua:114: in main chunk
[C]: ?

@craigbarnes
Copy link

I've been working on a fix for this. When I get time, I'll try to wrap up a patch.

@mauvm
Copy link

mauvm commented Nov 29, 2013

@craigbarnes Any indication when this will be fixed? Thanks in advance. :)

@craigbarnes
Copy link

@mauvm All I can say is "when I get time".

As a small pointer -- if you change line 893 of lunamark/reader/markdown.lua from:

(Blank^0 / function() return writer.interblocksep end * Block)^-0 *

to:

(Blank^0 / function() return writer.interblocksep end * Block)^-40 *

...and run make test, all except 6 of the tests pass.

This is not a real solution at all, since it makes the Blocks pattern always loop for 40 iterations, regardless of actual matches, but it shows that this empty loop is the only major problem to be fixed, and just needs a little rewriting.

@mauvm
Copy link

mauvm commented Dec 2, 2013

@craigbarnes Thanks for the quick response!

Unfortunately the suggested "fix" does not work for me. I can't really figure out why, except that the code I have does not have the negation sign:

(Blank^0 / function() return writer.interblocksep end * Block)^0 *

I have tried -0, 40 and -40, without any luck.. The problem seems to lie somewhere in the writer (instead of the reader), because lunamark/reader/markdown.lua is nowhere to be found in the stacktrace:

lua: /usr/local/share/lua/5.1/re.lua:183: loop body may accept empty string
    stack traceback:
[C]: in function 'f'
/usr/local/share/lua/5.1/re.lua:183: in function </usr/local/share/lua/5.1/re.lua:183>
[C]: in function 'match'
/usr/local/share/lua/5.1/re.lua:208: in function </usr/local/share/lua/5.1/re.lua:206>
(tail call): ?
/usr/local/share/lua/5.1/cosmo/grammar.lua:166: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/cosmo.lua:3: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/lunamark/util.lua:7: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/lunamark/writer/generic.lua:26: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/lunamark/writer/xml.lua:10: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/lunamark/writer/html.lua:9: in main chunk
[C]: in function 'require'
/usr/local/share/lua/5.1/lunamark/writer.lua:15: in function </usr/local/share/lua/5.1/lunamark/writer.lua:14>
test.lua:3: in main chunk
[C]: ?

To me it looks like a problem in the regexp in cosmo/grammar.lua:166. Hope it helps!

Also I'm quite new to Lua/LuaRocks and am not really sure where to run the make test command.

@craigbarnes
Copy link

The problem seems to lie somewhere in the writer (instead of the reader), because lunamark/reader/markdown.lua is nowhere to be found in the stacktrace
...
To me it looks like a problem in the regexp in cosmo/grammar.lua:166

Yes, sorry, I forgot to mention that. I'm using cosmo from git master, where compatibility with LPeg 0.12 is already fixed.

If you install the latest cosmo from the git repository, the error in Lunamark should cascade down to the line I mentioned. The -0 instead of 0 was my mistake, but using -40 should still demonstrate that it mostly "fixes" the problem, albeit not in a sensible way.

Also I'm quite new to Lua/LuaRocks and am not really sure where to run the make test command.

make test runs via the Makefile in the repository. LuaRocks doesn't install the Makefile or the tests, since they're only really for development purposes.

@catwell
Copy link

catwell commented Mar 9, 2014

Investigated this a little because this bug annoys me.

The issue is apparently in_matched_block_tags. If you comment out this line all tests pass except three.

I have no idea how this capture should be fixed though, this is as far as my current LPEG-fu gets.

@winks
Copy link

winks commented Jun 26, 2014

Quick addition
I used luarocks make lunamark-0.3-2.rockspec on luarocks installed with OpenResty 1.7.0.1 and I got this error with lpeg 0.12:

lua entry thread aborted: runtime error: ....7.0.1/luajit/share/lua/5.1/lunamark/reader/markdown.lua:974: empty loop in rule 'Blocks'
stack traceback:
coroutine 0:
        [C]: in function 'Ct'
        ....7.0.1/luajit/share/lua/5.1/lunamark/reader/markdown.lua:974: in function 'new'

After downgrading to lpeg 0.10.2-1 it seems to work.

@daurnimator
Copy link
Contributor

I'd like to think we can close this issue. lpeg 0.11 was a buggy release.
With #14 we work in lpeg 0.12 and 1.0.

@jgm jgm closed this as completed Apr 17, 2016
@winks
Copy link

winks commented Apr 17, 2016

Confirmed, lapis 1.5.0 pulled in lpeg 1.0 and lunamark 0.4 reused it?, basically everything works fine.

drehak pushed a commit to drehak/lunamark that referenced this issue May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants