djspiewak / anti-xml

The scala.xml library has some very annoying issues. Time for a clean-room replacement!
http://anti-xml.org
Other
169 stars 35 forks source link

XML.fromString(xmlString) throws StackOverflowException #75

Closed eirirlar closed 12 years ago

eirirlar commented 12 years ago

Using anti-xml 0.2 with scala 2.9.1.

val xmlString = new Scanner(this.getClass.getClassLoader.getResourceAsStream(thefilestring), "UTF-8").useDelimiter("\A").next val xml = XML.fromString(xmlString)

The above throws StackOverflowException on certain files like the one linked to below.

java.lang.StackOverflowError at java.util.regex.Pattern$Loop.match(Pattern.java:4683) at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615) at java.util.regex.Pattern$BranchConn.match(Pattern.java:4466) at java.util.regex.Pattern$CharProperty.match(Pattern.java:3694) at java.util.regex.Pattern$Branch.match(Pattern.java:4502) at java.util.regex.Pattern$GroupHead.match(Pattern.java:4556) at java.util.regex.Pattern$Loop.match(Pattern.java:4683) at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615) at java.util.regex.Pattern$BranchConn.match(Pattern.java:4466) at java.util.regex.Pattern$CharProperty.match(Pattern.java:3694) at java.util.regex.Pattern$Branch.match(Pattern.java:4502) ...

See this link for an example file that triggers this exception.

http://pastebin.com/5CmM8SY3

djspiewak commented 12 years ago

I added a spec for this issue and was unable to dup the error. Have you tried with version 0.3? Version 0.2 is a little outdated. Also, the stack overflow in this case looks more like it's coming from Scanner than from XML, but I may be mistaken there.

eirirlar commented 12 years ago

This is strange. I've rewritten my test to remove the Scanner \A inputstream thing:

val path = Paths.get(getClass.getProtectionDomain.getCodeSource.getLocation.toURI).resolve("jira-rss-derby-project.xml")
val string = new String(Files.readAllBytes(path),"UTF-8")
println(string)

// val xml = com.codecommit.antixml.XML.fromString(string) // println(xml)

This runs fine on my system. However, when I comment back in the two last lines, I get the stackoverflowexception (every time).

I run this on antixml 0.3, ubuntu 11.10 32bit, java sdk 7.01 32bit, scala 2.9.1, intellij idea 11 with idea.vmoptions: -Xms256m -Xmx1024m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=256m -ea

Regards, Eirik

djspiewak commented 12 years ago

Can you try running the Anti-XML test suite? You can do test-only *XMLSpecs to just get my version of your test case.