[
https://issues.apache.org/jira/browse/GROOVY-12844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18152533#comment-18152533
]
ASF GitHub Bot commented on GROOVY-12844:
-----------------------------------------
testlens-app[bot] commented on PR #3378:
URL: https://github.com/apache/groovy/pull/3378#issuecomment-7253291213
## 🚨 TestLens detected 2 failed tests 🚨
### Test Summary
> [!TIP]
> Inspect all details with the [TestLens
CLI](https://testlens.app/docs/features/cli): `testlens pr 3378`
#### [Build and test / lts \(25,
ubuntu-latest\)](https://github.com/apache/groovy/actions/runs/46242124478/job/141281066852?pr=3378)
> :test
| Test | Runs | Flakiness |
|---|---|--:|
| GrabResolverTest > testResolverDefinitionResolvesDependency\(\) | ❌ |
0% 🟢 |
| GrabResolverTest >
testResolverDefinitionResolvesDependencyWithShorthand\(\) | ❌ | 0% 🟢 |
🏷️ Commit: 3640aa730e8e4ae2a2570d60298208f4efacaf06
▶️ Tests: 73941 executed
🟡 Checks: 8/24 completed
### Test Failures
<details><summary><strong>GrabResolverTest >
testResolverDefinitionResolvesDependency()</strong> (:test in <a
href="https://github.com/apache/groovy/actions/runs/46242124478/job/141281066852?pr=3378">Build
and test / lts (25, ubuntu-latest)</a>)</summary>
```
java.lang.AssertionError: Forked JVM for
groovy.grape.GrabResolverTest#testResolverDefinitionResolvesDependency failed:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
failed:
General error during conversion: Error grabbing Grapes
> groovy-contracts: StackOverflowError when a contract calls a checked method
> more than once
> ------------------------------------------------------------------------------------------
>
> Key: GROOVY-12844
> URL: https://issues.apache.org/jira/browse/GROOVY-12844
> Project: Groovy
> Issue Type: Bug
> Components: groovy-contracts
> Affects Versions: 6.0.0, 6.0.1
> Reporter: Paul King
> Priority: Major
>
> A class invariant that makes two calls to methods of its own class overflows
> the stack:
> {code:groovy}
> import groovy.contracts.*
> @Invariant({ lo <= hi })
> class Range {
> int getLo() { 1 }
> int getHi() { 2 }
> }
> new Range() // StackOverflowError
> {code}
> The same happens when one getter or method is called twice, e.g. {{v > 0 && v
> < 9}}, and for a {{@Requires}} or {{@Ensures}} that calls its own method
> twice, e.g. {{@Ensures({ m(1) > 0 && m(2) > 0 })}} on {{m}}. A single call
> works, as do ordinary properties of the class ({{int lo = 1, hi = 2}}). The
> invariant was tried in dynamic and statically compiled code, with the same
> result. All of these fail on 6.0.0, 6.0.1 and master.
> h3. Trait properties, from 6.0.1
> Reading a trait property once is enough:
> {code:groovy}
> trait T { Integer count }
> @Invariant({ count == null || count >= 0 })
> class C implements T { }
> new C() // 6.0.0: no error; 6.0.1: StackOverflowError
> {code}
> Two generated accessors are involved in one read ({{getCount}} and
> {{T__count$get}}), and both check the invariant. On 6.0.0 the check in those
> accessors wasn't run. Since GROOVY-12742 it is, which exposes this problem.
> 6.0.0 didn't handle these invariants properly either: its accessors returned
> null, so only an invariant that allows null passed.
> It's easy to meet on 6.0.1, since GROOVY-12741 advises moving a trait's
> invariant to the implementing class.
> h3. Cause
> {{ContractExecutionTracker}} should stop a contract from checking itself
> again while it runs. The code generated by
> {{BaseGenerator.wrapAssertionBooleanExpression}} is, in effect:
> {code:java}
> try {
> if (ContractExecutionTracker.track(...)) {
> // evaluate the condition
> }
> } finally {
> ContractExecutionTracker.clear(...);
> }
> {code}
> A nested check is refused by {{track}}, but still runs {{clear}}, which
> removes the outer check's entry. The next call from the same condition is
> then no longer recognised as nested, and evaluates the condition again,
> without end.
> h3. Possible fix
> Clear only what was tracked:
> {code:java}
> if (ContractExecutionTracker.track(...)) {
> try {
> // evaluate the condition
> } finally {
> ContractExecutionTracker.clear(...);
> }
> }
> {code}
> With this change on master, all the forms above work, including the trait
> properties, and violations are still reported, also on a second call after a
> first violation.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)