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

Stringification of XML values causes StackOverflowError #7658

Closed
scabug opened this issue Jul 13, 2013 · 2 comments
Closed

Stringification of XML values causes StackOverflowError #7658

scabug opened this issue Jul 13, 2013 · 2 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jul 13, 2013

I started to see two new test failures on Avian, but the issue exists on all runtimes.

The code ends up in an endless recursion by the changes to the stringOf method in ScalaRuntime (scala/scala@739cc9d#src/library/scala/runtime/ScalaRunTime.scala).

The reason why it seems to work fine on Hotsopt is just that Hotspot copes better with StackOverflowErrors than Avian and is in a less broken state after catching the SOE:

    try inner(arg)
    catch {
      case _: StackOverflowError | _: UnsupportedOperationException | _: AssertionError => "" + arg
    }

Don't be mistaken: Even on Hotspot stringifying XML values causes SOEs which are then catched and thrown away.

Stacktraces look like this:

...
scala> val atom = new scala.xml.Atom()
java.lang.ExceptionInInitializerError
at scala.xml.Node.buildString(Node.scala:162)
at scala.runtime.ScalaRunTime$.scala$runtime$ScalaRunTime$$inner$1(ScalaRunTime.scala:313)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
at scala.collection.TraversableOnce$class.addString(TraversableOnce.scala:343)
at scala.collection.TraversableOnce$class.mkString(TraversableOnce.scala:309)
at scala.runtime.ScalaRunTime$.scala$runtime$ScalaRunTime$$inner$1(ScalaRunTime.scala:316)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
at scala.collection.TraversableOnce$class.addString(TraversableOnce.scala:343)
at scala.collection.TraversableOnce$class.mkString(TraversableOnce.scala:309)
...

or

...
java.lang.NoClassDefFoundError: scala.xml.Utility$
at scala.xml.Node.buildString(Node.scala:162)
at scala.runtime.ScalaRunTime$.scala$runtime$ScalaRunTime$$inner$1(ScalaRunTime.scala:313)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
at scala.collection.TraversableOnce$class.addString(TraversableOnce.scala:343)
at scala.collection.TraversableOnce$class.mkString(TraversableOnce.scala:309)
at scala.runtime.ScalaRunTime$.scala$runtime$ScalaRunTime$$inner$1(ScalaRunTime.scala:316)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
...
Caused by: java.lang.StackOverflowError
... 10888 more
@scabug
Copy link
Author

scabug commented Jul 13, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7658?orig=1
Reporter: @soc
Affected Versions: 2.11.0-M4

@scabug
Copy link
Author

scabug commented Aug 16, 2013

@adriaanm said:
scala/scala#2803

@scabug scabug closed this as completed Aug 16, 2013
@scabug scabug added this to the 2.11.0-M5 milestone Apr 7, 2017
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