Navigation Menu

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

VerifyError Stack size too large #466

Closed
robfletcher opened this issue Aug 30, 2015 · 10 comments
Closed

VerifyError Stack size too large #466

robfletcher opened this issue Aug 30, 2015 · 10 comments

Comments

@robfletcher
Copy link
Contributor

Originally reported on Google Code with ID 344

Run this repo case: https://gist.github.com/Pyrolistical/8741574

Run with "groovy bug.groovy"

Version:
Spock: 0.7-groovy-2.0
$ groovy -v
Groovy Version: 2.2.1 JVM: 1.7.0_40 Vendor: Oracle Corporation OS: Mac OS X

I get the failure:
$ groovy bug.groovy 
Caught: java.lang.VerifyError: (class: BuggedTest, method: $spock_feature_0_0 signature:
()V) Stack size too large
java.lang.VerifyError: (class: BuggedTest, method: $spock_feature_0_0 signature: ()V)
Stack size too large

There is something wrong with the generated code.  There is some poor interaction with
calling helperMethod() and putting the result into an array.

Things that avoid this bug:
1. inline the helperMethod()
2. change the then: to "assert true"
3. change the when: to "assert thing == null"
4. move the def thing into the given:
5. remove the list literal around helperMethod()

It has been talked about here: https://groups.google.com/forum/#!topic/spockframework/vKRej9PJ5B0
But never solved.

Reported by ronald.p.chen on 2014-01-31 19:56:58

@robfletcher
Copy link
Contributor Author

Another way to avoid the bug is to put new line char after [

The fact whitespace avoids the bug tells me something is seriously wrong with the way
the spec is transformed into the generated code

Reported by ronald.p.chen on 2014-01-31 20:00:54

@robfletcher
Copy link
Contributor Author

Works just fine for me.

Reported by pniederw on 2014-01-31 23:44:24

@robfletcher
Copy link
Contributor Author

I have a situation that I think is the same bug. In a Geb spec, I have the following
class:

@Stepwise
abstract class AbstractAboutPageSpec extends Specification {
    abstract Class<? extends AboutPage> page()

    def "page loads"() {
        when: to page();
        then: {}
    }
}

This produces a VerifyError on run:
java.lang.VerifyError: (class: com/artsquare/gallery/acceptance/ui/AbstractAboutPageSpec,
method: $spock_feature_3_0 signature: ()V) Stack size too large
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2575)
    at java.lang.Class.getDeclaredFields(Class.java:1908)
    at org.spockframework.runtime.SpecInfoBuilder.buildFields(SpecInfoBuilder.java:98)
    at org.spockframework.runtime.SpecInfoBuilder.doBuild(SpecInfoBuilder.java:69)
    at org.spockframework.runtime.SpecInfoBuilder.buildSuperSpec(SpecInfoBuilder.java:80)
    at org.spockframework.runtime.SpecInfoBuilder.doBuild(SpecInfoBuilder.java:67)
    at org.spockframework.runtime.SpecInfoBuilder.build(SpecInfoBuilder.java:54)
    at org.spockframework.runtime.Sputnik.getSpec(Sputnik.java:80)
    at org.spockframework.runtime.Sputnik.runExtensionsIfNecessary(Sputnik.java:88)
    at org.spockframework.runtime.Sputnik.getDescription(Sputnik.java:55)
    at org.junit.runner.Runner.testCount(Runner.java:41)

Modifying the spec so that the method is called in a given: block fixes the problem:

    def "page loads"() {
        given: Class<AboutPage> page = page()
        when: to page
        then: {}
    }

Reported by christopher.smith@artsquare.com on 2015-02-27 09:21:35

@bartoszwalacik
Copy link

I have the same problem using IntelliJ 2016.2 and spock-core 1.0-groovy-2.4.
Thanks @robfletcher, your workaround with new line after [ works for me :)

@gregopet
Copy link

Same issue with org.spockframework:spock-core:1.1-groovy-2.4-rc-3, workaround still works

@leonard84
Copy link
Member

Same with org.spockframework:spock-core:1.1-groovy-2.4, but this seems to be more of an groovy issue than a spock issue. @danielsun1106 do you have an idea why this is happening? The SpecInfoBuilder.buildFields is executed before any actual test code is run.

@najor
Copy link

najor commented Feb 26, 2018

Have similar situation when accessing metaclass.static. Resolved moving the metaclass.static assignment to the setup: closure:

    def "some"() {
        setup:
        Domain.metaClass.static.findAll = {
            [new Domain()]
        }

        when:
        ...

        then:
        ....
    }

@Arrvi
Copy link

Arrvi commented Dec 21, 2018

Got similar issue while using java reflection on a Spock test class (custom test scanner). My workaround was to move mock return value to variable:

def "this fails"() {
    given:
    mockedService.find(SEARCH_TERM, LIMIT) >> createResultsList(20, 30)

    when:
    def results = facadeUnderTest.find(SEARCH_TERM)

    then:
    results.propA.size() == 20
    results.propB.size() == 30
    !results.isTooManyResults
}

def "this works"() {
    given:
    def queryResults = createResultsList(20, 30)
    mockedService.find(SEARCH_TERM, LIMIT) >> queryResults

    when:
    def results = facadeUnderTest.find(SEARCH_TERM)

    then:
    results.propA.size() == 20
    results.propB.size() == 30
    !results.isTooManyResults
}

private static List<SomeObject> createResultsList(int current, int other) {
    (1..current).collect {
        new SomeObject(prop: CURRENT_VALUE)
    } + (1..other).collect {
        new SomeObject(prop: OTHER_VALUE)
    }
}

Stacktrace:

java.lang.VerifyError: (class: (...)FacadeTest, method: returns exact amount of results if on limit, does not mark too many results signature: ()Ljava/lang/Object;) Stack size too large
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.privateGetPublicMethods(Class.java:2902)
	at java.lang.Class.getMethods(Class.java:1615)
	...

Spock: 1.1-groovy-2.4
Groovy: 2.4.11

(names of classes and fields in example were changed to mask proprietary code)

@daniellansun
Copy link
Contributor

daniellansun commented Dec 21, 2018

Please submit a JIRA ticket to track the issue of groovy, I have no idea at the first glance.
It would be great if you could attach an independent/minimum sample code to reproduce the issue.

@Vampire
Copy link
Member

Vampire commented Mar 25, 2020

I would say this issue can be closed as obsolete.
I can reproduce with 1.3-groovy-2.4.
I can not reproduce with 1.3-groovy-2.5.
So this indeed seems to have been a Groovy bug that was fixed in 2.5.
As Spock 2.0 drops Groovy 2.4 support, there is nothing left to do.

@szpak szpak closed this as completed Mar 25, 2020
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

9 participants