StackOverflowError

519 views
Skip to first unread message

John Threepwood

unread,
Aug 27, 2012, 8:05:29 AM8/27/12
to specs2...@googlegroups.com
Hello community,
 
I have been working with Specs2 quite a while and never had a greater issue with it. But after extending my test cases, I keep getting an StackOverflowError:
 
Exception in thread "main" java.lang.reflect.InvocationTargetException
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.runSingleTest(JavaSpecs2Runner.java:95)
 at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.main(JavaSpecs2Runner.java:76)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.StackOverflowError
 at org.specs2.internal.scalaz.Foldable$$anon$13$$anonfun$foldRight$6.apply(Foldable.scala:95)
 at org.specs2.internal.scalaz.Tree$$anonfun$org$specs2$internal$scalaz$Tree$$squish$1$$anonfun$apply$3.apply(Tree.scala:52)
 at org.specs2.internal.scalaz.Tree$$anonfun$org$specs2$internal$scalaz$Tree$$squish$1$$anonfun$apply$3.apply(Tree.scala:52)
 at org.specs2.internal.scalaz.Foldable$$anon$13.foldRight(Foldable.scala:95)
 at org.specs2.internal.scalaz.Foldable$$anon$13$$anonfun$foldRight$6.apply(Foldable.scala:95)
 at org.specs2.internal.scalaz.Tree$$anonfun$org$specs2$internal$scalaz$Tree$$squish$1$$anonfun$apply$3.apply(Tree.scala:52)
 at org.specs2.internal.scalaz.Tree$$anonfun$org$specs2$internal$scalaz$Tree$$squish$1$$anonfun$apply$3.apply(Tree.scala:52)
 
I could not isolate the problem to a specific test case. The error appears sometimes when executing much test cases.
 
Can someone please explain what the problem is ? Do I simply not have enough main memory or is the error a sign for a wrong Specs2 test case setup ?
 
Thank you, John

etorreborre

unread,
Aug 27, 2012, 8:28:51 AM8/27/12
to specs2...@googlegroups.com
Hi John,

This seems to be characteristic of a foldRight implementation which is not tail-recursive. You might be able to temporarily workaround this by increasing your -Xss setting (or breaking your specification into smaller ones), but I'd like to investigate that in more detail.

Can you give me more details about your specification? How many examples do you have?

Thanks,

Eric.

John Threepwood

unread,
Aug 27, 2012, 9:24:10 AM8/27/12
to specs2...@googlegroups.com
Thank you Eric.
 
1. Increasing  -Xss from 1m to 10m and 100m did not help
2. Breaking down the tests into separate one (that means writing separate "should" cases instead of all tests into just one "should" statement) did not help
 
3. All in all, I have around 140 calls of the "should" statement which itself has around 5 calls of the "in"-statement.
    To avoid duplicate code, I use helper methods like:
 
    class MyTest extends Specification {
       sequential
       helpMethod("a")
       helpMethod("b")
       helpMethod("c")
 
      def helpMethod(...) {
          innerHelpMethod(1)
          innerHelpMethod(2)
          innerHelpMethod(3)
          ....
      }
 
     def innerHelpMethod(...) {
         "..." should {
            "... " in {
                ...
            }
         }
      }
   }
 
  Could the sequential-statement or the help methods cause the problem ?
 
4. I use Intellij IDEA, where I can only see the last piece in the error stack output. Is it possible to view the whole output ? Maybe one can see what triggers the problem.
 
5. I would like to give you more information, but unfortunately I can not post my original tests here because of company restrictions. And I can not reduce or isolate the problem to a smaller one. The error appears when I start all tests, and disappears when I only start a part of the tests (which part is not relevant, all parts for itself run through successfull).
 
Greetings, John

John Threepwood

unread,
Aug 27, 2012, 10:45:18 AM8/27/12
to specs2...@googlegroups.com
Additional information:
Running the test with the simple build tool and the command line argument "test", all works fine.
So this might be an Intellij IDEA related issue with the Scala plugin and the Specs2 support ?

etorreborre

unread,
Aug 27, 2012, 7:08:30 PM8/27/12
to specs2...@googlegroups.com
Hi John,

This was indeed a foldLeft vs foldRight issue and it is fixed in the latest 1.12.2-SNAPSHOT.

Thanks for reporting this problem,

Eric.

John Threepwood

unread,
Aug 28, 2012, 4:45:31 AM8/28/12
to specs2...@googlegroups.com
Thank you for the information, Eric.
 
I could not figure out from the Intellij IDEA Homepage which Specs2 version the Scala Plugin uses.
Or am I searching at the wrong place and Intellij IDEA does not provide its own Specs2 library ?
 
Thank you, John

etorreborre

unread,
Aug 28, 2012, 6:26:03 AM8/28/12
to specs2...@googlegroups.com
I don't know how you created your IDEA project but there should be a dependency to the specs2 jar in the "Dependencies" tab of your module. This is the one you need to update.

E.

John Threepwood

unread,
Aug 28, 2012, 7:25:38 AM8/28/12
to specs2...@googlegroups.com
Okay. I replaced the libraries in the project settings with the current snapshot 1.12.2 .
Now the tests run through, no error as before. Great, thank you.
 
But unfortunately there comes a new problem up with the snapshot.
Running the Specs2 test from inside Intellij IDEA, I get an message on the console "Empty test suite" and the result graphics in IDEA does not show the test hierarchy correctly.
Normally, I have:
TestResults
- should statement
- - in statement
 
Now I have:
TestResults
- - in statement
 
Could this behavior come from the latest snapshot which is not fully supported by the IDEA plugin yet ?
 
Greetings, John

etorreborre

unread,
Aug 28, 2012, 8:38:07 AM8/28/12
to specs2...@googlegroups.com
The latest snapshot should have not effect on the plugin by itself because the intellij plugin is using an interface that hasn't changed.

However there were some changes in 1.12 which might have some effect, as I had to change bits of the implementation.

Could you give me a small example (and maybe the version number of your idea/scala plugin installation)? When I try this:

class TestSpec extends Specification {
  "this " should {
    "be ok" in ok
    "be ok2" in ok
  }
}

Everything looks ok.

E.

John Threepwood

unread,
Aug 28, 2012, 9:11:59 AM8/28/12
to specs2...@googlegroups.com
The behavior is still the same with your example.
 
I set up a new project in Intellij IDEA with:
- Added jar libraries: specs2_2.9.2-1.12.2-SNAPSHOT.jar  and  specs2-scalaz-core_2.9.2-6.0.1.jar
- Intellij IDEA Community Edition 11.1.3, built on 25th July, 2012
- Scala Plugin 0.5.948
- SBT Plugin 1.3.1
- Scala 2.9.1
- Java 1.6, 32 Bit
 
Test.scala :
import org.specs2.mutable._
class Test extends Specification {

  "this " should {
    "be ok" in ok
    "be ok2" in ok
  }
}
 
Console output :
"C:\Program Files (x86)\Java\jdk1.6.0_32\bin\java" -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 11.1.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\John\.IdeaIC11\config\plugins\Scala\lib\scala-plugin-runners.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\charsets.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\deploy.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\javaws.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\jce.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\jsse.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\management-agent.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\plugin.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\resources.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\rt.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\ext\dnsns.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\ext\localedata.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\ext\sunjce_provider.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\ext\sunmscapi.jar;C:\Program Files (x86)\Java\jdk1.6.0_32\jre\lib\ext\sunpkcs11.jar;C:\Users\John\Test Scala Project 3\target\scala-2.9.1\test-classes;C:\Users\John\Test Scala Project 3\target\scala-2.9.1\classes;C:\Users\John\.sbt\boot\scala-2.9.1\lib\scala-library.jar;C:\Users\John\Desktop\Specs2\specs2-scalaz-core_2.9.2-6.0.1.jar;C:\Users\John\Desktop\Specs2\specs2_2.9.2-1.12.2-SNAPSHOT.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 11.1.1\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner -s Test -showProgressMessages true -C org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Notifier
Testing started at 15:02 ...
Empty test suite.
be ok2
be ok
Process finished with exit code 0
 
Graphical output on the left corner looks like:
TestResults
- Test
- be ok2
- be ok
If you need any further information about which setup I use, please let me know.
 
Thank you, John

etorreborre

unread,
Aug 28, 2012, 9:21:40 AM8/28/12
to specs2...@googlegroups.com
Great, I reproduced it. Apparently *I* was not trying with the proper version,...

I'll have a go at that tomorrow, thanks.

etorreborre

unread,
Aug 28, 2012, 8:55:06 PM8/28/12
to specs2...@googlegroups.com
John, the latest 1.12.2-SNAPSHOT should now provide the correct display (and not StackOverFlow).

John Threepwood

unread,
Aug 29, 2012, 6:31:32 AM8/29/12
to specs2...@googlegroups.com
Thank you Eric, it works well now.
 
Unfortunately I have to come up with another issue related to the latest snapshot:
When I have two test files in a test directore, like "src/test/scala/Test1.scala" and "src/test/scala/Test2.scala", I can not start them both by right-clicking on the directory "scala" and click "Run '!Specs2 in 'scala'!' ". It only executes one of the test files (and displays just one result).
 
With the old version, I was able to do so. Is this missing feature a bug or intentionally removed ?
 
Greetings, John

etorreborre

unread,
Aug 29, 2012, 10:56:29 PM8/29/12
to specs2...@googlegroups.com
John, I'm observing the same issue with specs2-1.12.1, which version was for you the "old" version? (it might be a specs2 plugin in IDEA regression also)

John Threepwood

unread,
Aug 30, 2012, 4:59:46 AM8/30/12
to specs2...@googlegroups.com
Sorry, I should have been more precise on that.

I used "specs2_2.9.0-1-1.8.2.jar" with "specs2-scalaz-core_2.9.0-1-6.0.RC2.jar" before.

Greetings, John

John Threepwood

unread,
Sep 4, 2012, 11:23:04 AM9/4/12
to specs2...@googlegroups.com
Right at the moment, this missing feature is not a big problem for me.
And I am sure there is a lot more important to do for Specs2, but out of my interests, I would like to know when is it expected to fix this issue?

Thank you, John

etorreborre

unread,
Sep 4, 2012, 6:06:29 PM9/4/12
to specs2...@googlegroups.com
I'm pretty busy and / or disconnected this week and I have one or 2 specs2 issues in the pipe already.

What I need to do on this is make sure that the issue is with specs2 and not with the Scala plugin, because it seems to me that the multiple selection of classes to execute in Intellij is outside of my scope. If that's the case, I'll create an issue for the Jetbrains team.

E.

etorreborre

unread,
Sep 6, 2012, 2:33:18 AM9/6/12
to specs2...@googlegroups.com
Hi John,

This is an integration issue. I did a change a while ago to send exit codes when a runner was done, but then the whole Intellij run finishes right after the first specification.

I've created an issue to track that: http://youtrack.jetbrains.com/issue/IDEA-91104.

Thanks for reporting this problem,

Eric.

John Threepwood

unread,
Sep 6, 2012, 2:27:28 PM9/6/12
to specs2...@googlegroups.com
Thank you, Eric, for working on this (minor) issue that fast. I know there are a lot more important issues with Specs2.

John
Reply all
Reply to author
Forward
0 new messages