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

knockoff method throws StackOverflowError #35

Open
ardok opened this issue Aug 29, 2013 · 9 comments
Open

knockoff method throws StackOverflowError #35

ardok opened this issue Aug 29, 2013 · 9 comments

Comments

@ardok
Copy link

ardok commented Aug 29, 2013

I'm using Scala 2.10.2, hence using 0.8.1 version.

Calling knockoff method keeps throwing me this:

java.lang.StackOverflowError: null
at java.util.regex.Pattern.group0(Pattern.java:2513) ~[na:1.6.0_26]
at java.util.regex.Pattern.sequence(Pattern.java:1806) ~[na:1.6.0_26]
at java.util.regex.Pattern.expr(Pattern.java:1752) ~[na:1.6.0_26]
at java.util.regex.Pattern.compile(Pattern.java:1460) ~[na:1.6.0_26]
at java.util.regex.Pattern.(Pattern.java:1133) ~[na:1.6.0_26]
at java.util.regex.Pattern.compile(Pattern.java:823) ~[na:1.6.0_26]
at scala.util.matching.Regex.(Regex.scala:153) ~[scala-library-2.10.2.jar:na]
at scala.collection.immutable.StringLike$class.r(StringLike.scala:224) ~[scala-library-2.10.2.jar:na]
at scala.collection.immutable.StringOps.r(StringOps.scala:31) ~[scala-library-2.10.2.jar:na]
at scala.collection.immutable.StringLike$class.r(StringLike.scala:213) ~[scala-library-2.10.2.jar:na]
at scala.collection.immutable.StringOps.r(StringOps.scala:31) ~[scala-library-2.10.2.jar:na]
at com.tristanhunt.knockoff.ChunkParser$$anon$1.findEnd(MarkdownParsing.scala:261) ~[knockoff_2.10-0.8.1.jar:0.8.1]
at com.tristanhunt.knockoff.ChunkParser$$anon$1.findEnd(MarkdownParsing.scala:270) ~[knockoff_2.10-0.8.1.jar:0.8.1]
at com.tristanhunt.knockoff.ChunkParser$$anon$1.findEnd(MarkdownParsing.scala:270) ~[knockoff_2.10-0.8.1.jar:0.8.1]
at com.tristanhunt.knockoff.ChunkParser$$anon$1.findEnd(MarkdownParsing.scala:270) ~[knockoff_2.10-0.8.1.jar:0.8.1]
at com.tristanhunt.knockoff.ChunkParser$$anon$1.findEnd(MarkdownParsing.scala:270) ~[knockoff_2.10-0.8.1.jar:0.8.1]
at com.tristanhunt.knockoff.ChunkParser$$anon$1.findEnd(MarkdownParsing.scala:270) ~[knockoff_2.10-0.8.1.jar:0.8.1]
at com.tristanhunt.knockoff.ChunkParser$$anon$1.findEnd(MarkdownParsing.scala:270) ~[knockoff_2.10-0.8.1.jar:0.8.1]
at com.tristanhunt.knockoff.ChunkParser$$anon$1.findEnd(MarkdownParsing.scala:270) ~[knockoff_2.10-0.8.1.jar:0.8.1]
at com.tristanhunt.knockoff.ChunkParser$$anon$1.findEnd(MarkdownParsing.scala:270) ~[knockoff_2.10-0.8.1.jar:0.8.1]
at com.tristanhunt.knockoff.ChunkParser$$anon$1.findEnd(MarkdownParsing.scala:270) ~[knockoff_2.10-0.8.1.jar:0.8.1]

Any idea?

Oh and just to add more info, using the version for Scala 2.9 works just fine.

UPDATE 08/29/13 10:06 : will try increasing stack size and cross my fingers

@tristanjuricek
Copy link
Owner

I haven't done anything in Scala in a while, so I'm not sure. I'll check it out when I have some free time.

The expression that's failing is

"(?i)<[ ]*" + tagName + "[ ]*[^>]*>"

This is a basic search for HTML tags. I may have to sanitize that tag name, is there any kind of interesting HTML in the document you're trying to parse?

@devmage
Copy link

devmage commented Aug 29, 2013

I'm one of @ardok 's colleagues. We ran JProfiler against this section of code. Just to show you: http://i.imgur.com/bv63l36.png

That CPU time tree is from 3-4 minutes of execution time, most of which were spent compiling a markdown file we have. The tree extends quite far beyond what is shown here.

@tristanjuricek
Copy link
Owner

I just updated the 2.10 build to 2.10.2, it doesn't really seem that it's build related at all, which makes sense.

How are HTML tags being used? Is there any stretch of code that appears like an HTML tag? Like <foo?

@ardok
Copy link
Author

ardok commented Aug 30, 2013

I don't think there is any.
There was something like [link](blah blah without parenthese closure and it gave us None.get error.
After fixing that, we faced that StackOverflowError. It's just that recursive findEnd method.
What I did to "fix" it is reverting your HTMLBlock changes and making it Scala 2.10 ready.
Markdown loads much faster than using HTMLBlock.

@ardok
Copy link
Author

ardok commented Sep 9, 2013

FYI, this is what we're currently using: https://github.com/ardok/knockoff/tree/non-recursive

I reverted your master branch to this commit: 74bfe4b (before you add emptySpace) and updated it to use Scala 2.10

@tristanjuricek
Copy link
Owner

Thanks!

What I really use is a reproduction case, I'm still not able to actually
generate the problem this change solves.

-Tristan

On Mon, Sep 9, 2013 at 1:42 PM, Ardo [email protected] wrote:

FYI, this is what we're currently using:
https://github.com/ardok/knockoff/tree/non-recursive

I reverted your master branch to this commit: 74bfe4bhttps://github.com/tristanjuricek/knockoff/commit/74bfe4bc3b6cdddcd417f38e1514b5574c11c44aand updated it to use Scala 2.10


Reply to this email directly or view it on GitHubhttps://github.com//issues/35#issuecomment-24112835
.

@ardok
Copy link
Author

ardok commented Sep 9, 2013

Give this a shot with your master branch: https://github.com/stackmob/stackmob-docs/blob/master/sdks/ios/guides/developer.md

@razie
Copy link

razie commented Oct 9, 2013

i just had the same issue on a fresh install of a scala play app on a ubuntu 32 bit VM. the exact same install on a 64 bit VM works fine - can't explain it, but it must be due to some environment issues.

the content it tries to parse has a few html tags, yes... without the tags it works fine every time.

i'm using 0.8.1

@ardok
Copy link
Author

ardok commented Oct 9, 2013

The one that works fine for me is this from this commit (dated July 22, 2012): 74bfe4b

I forked from that commit and update it to use scala 2.10.2.
This is what I'm using for now: https://github.com/ardok/knockoff/tree/non-recursive

If you're gonna use my forked repo, just remember to change the version in build.sbt since it has my name on the version build.

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

4 participants