rksm / paredit.js

Generic reader and editor for s-expressions.
MIT License
107 stars 21 forks source link

Parsing really big s-expressions causes endless loop #4

Closed sjlevine closed 9 years ago

sjlevine commented 9 years ago

Hi again,

@tvaquero and I seem to have found a bug in paredit.js where parsing a really large s-expression causes this error:

Uncaught Error: endless loop at
{"idx":71391,"column":1,"row"2501}

I haven't had time to delve deeper, but wanted to make you aware of it!

I would upload a test file that is causing this crash, but I can't seem to figure out how to do that on github. So, here's a quick Python script (big.py) that, when run, outputs a a 3000-line or so Lisp file (big.lisp) that exhibits the above problem.

#!/usr/bin/env python
N = 3000
print "(in-package :cl-user)"
print ""
print "(defmethod really-big-function ()"
for i in range(N):
    print "  (do-something-else 'i{})".format(i)
print "  (finally-the-end))"

Then you can run it with:

python big.py > big.lisp

If you try and parse the resulting big.lisp file, you should see the error.

Thanks again for your hard work on this library; it is much appreciated!

rksm commented 9 years ago

Thanks, this was a stupid hack from me.

sjlevine commented 9 years ago

Thanks so much!