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

Quadratic time consumption on pathological input #31

Closed
DemiMarie opened this issue Aug 6, 2017 · 3 comments
Closed

Quadratic time consumption on pathological input #31

DemiMarie opened this issue Aug 6, 2017 · 3 comments

Comments

@DemiMarie
Copy link
Contributor

See commonmark/cmark#218. Comrak is also vulnerable:

$ python -c 'print("[a](<b"*50000)' | time comrak >/dev/null
comrak > /dev/null  6.78s user 0.01s system 99% cpu 6.810 total
@kivikakk
Copy link
Owner

Is this actually quadratic right now?

$ time python -c 'print("[a](<b" * 50000)' | target/debug/comrak > /dev/null
target/debug/comrak > /dev/null  1.39s user 0.02s system 98% cpu 1.431 total
$ time python -c 'print("[a](<b" * 100000)' | target/debug/comrak > /dev/null
target/debug/comrak > /dev/null  2.93s user 0.05s system 99% cpu 3.007 total
$ time python -c 'print("[a](<b" * 200000)' | target/debug/comrak > /dev/null
target/debug/comrak > /dev/null  5.41s user 0.07s system 99% cpu 5.505 total

Time taken is roughly doubling with each doubling of input size.

@DemiMarie
Copy link
Contributor Author

DemiMarie commented Aug 28, 2017 via email

@kivikakk
Copy link
Owner

Oh, you're totally right. I was not awake when I checked this issue last, sorry. Thanks again for #33!

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

2 participants