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

OutOfMemoryErrors and inifinte loops in scala.xml.parsing.ConstructingParser #4520

Closed
scabug opened this issue Apr 27, 2011 · 6 comments
Closed

Comments

@scabug
Copy link

scabug commented Apr 27, 2011

=== What steps will reproduce the problem? ===

val x = xml.parsing.ConstructingParser.fromSource(io.Source.fromString("<foo/>"), false)

x.xCharData
:1:1: '[' expected instead of _^
:1:1: 'C' expected instead of _^
:1:1: 'D' expected instead of _^
:1:1: 'A' expected instead of _^
:1:1: 'T' expected instead of _^
:1:1: 'A' expected instead of _^
:1:1: '[' expected instead of _^
java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:2894)
	at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:117)
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:589)
	at java.lang.StringBuilder.append(StringBuilder.java:220)
	at scala.collection.mutable.StringBuilder.append(StringBuilder.scala:252)
	at scala.xml.parsing.MarkupParserCommon$$class.xTakeUntil(MarkupParserCommon.scala:243)
	at scala.xml.parsing.ConstructingParser.xTakeUntil(ConstructingParser.scala:47)
	at scala.xml.parsing.MarkupParser$$class.xCharData(MarkupParser.scala:349)
	at scala.xml.parsing.ConstructingParser.xCharData(ConstructingParser.scala:47)

x.xCharRef
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^

:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref
^
:1:1: character _ not allowed in char ref


x.xComment
:1:1: '-' expected instead of '<'foo/>^
:1:1: '-' expected instead of '<'^
java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:2894)
	at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:117)
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:589)
	at java.lang.StringBuilder.append(StringBuilder.java:220)
	at scala.collection.mutable.StringBuilder.append(StringBuilder.scala:252)
	at scala.xml.parsing.MarkupParser$$class.xComment(MarkupParser.scala:365)
	at scala.xml.parsing.ConstructingParser.xComment(ConstructingParser.scala:47)

=== What is the expected behavior? ===
It should do something sensible.

=== What do you see instead? ===
xCharData, xComment: java.lang.OutOfMemoryError: Java heap space
xCharRef: Just loops.

=== What versions of the following are you using? ===

  • Scala: 2.10.0.r24736-b20110412020139
@scabug
Copy link
Author

scabug commented Apr 27, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4520?orig=1
Reporter: @soc
See #4339
Attachments:

@scabug
Copy link
Author

scabug commented Apr 27, 2011

@harrah said:
This is a regression from 2.7.7, where the output was:

scala> x.xCharData
:1:1: '[' expected instead of '<'<foo/>^
java.lang.RuntimeException: FATAL
	at scala.Predef$$.error(Predef.scala:76)
	at scala.xml.parsing.MarkupParser$$class.xToken(MarkupParser.scala:267)
	at scala.xml.parsing.ConstructingParser.xToken(ConstructingParser.scala:56)
	at scala.xml.parsing.MarkupParser$$class.xToken(MarkupParser.scala:274)
	at scala.xml.parsing.ConstructingParser.xToken(ConstructingParser.scala:56)

The cause was the refactoring of !MarkupParser* in r20212, which dropped the error("FATAL") from the library version of xToken. Attached is a patch with a sample fix.

@scabug
Copy link
Author

scabug commented May 30, 2011

@dcsobral said:
Duplicate of #4339.

@scabug
Copy link
Author

scabug commented Dec 23, 2014

@som-snytt said:
Actually not a duplicate.

@scabug
Copy link
Author

scabug commented Jul 17, 2015

@SethTisue said:
The scala-xml library is now community-maintained. Issues with it are now tracked at https://github.com/scala/scala-xml/issues instead of here in the Scala JIRA.

Interested community members: if you consider this issue significant, feel free to open a new issue for it on GitHub, with links in both directions.

@scabug scabug closed this as completed Jul 17, 2015
@scabug
Copy link
Author

scabug commented Jul 18, 2015

@som-snytt said:
There's an old WIP at scala/scala-xml#32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant