[
https://issues.apache.org/jira/browse/MNG-6737?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tomo Suzuki updated MNG-6737:
-----------------------------
Description:
Maven throws StackOverflowError when version ranges are unsolvable and the
dependency graph contains a cycle.
{code:java}
$ mvn install
...
[INFO] --------------------------< suztomo:module-c >--------------------------
[INFO] Building module-c 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.406 s
[INFO] Finished at: 2019-08-16T12:10:30-04:00
[INFO] ------------------------------------------------------------------------
...
Exception in thread "main" java.lang.StackOverflowError
at
org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:341)
at
org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
at
org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
at
org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
at
org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
at
org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
...(omitting many lines)...
{code}
h1. Example
Example project to reproduce the issue:
[https://github.com/suztomo/maven-cyclic-dependency-with-range]
h1. Diagnosis
In the example above, because of a version conflict on grpc-core (1.21.0 v.s.
1.16.1),
[org.eclipse.aether.util.graph.transformer.NearestVersionSelector.newFailure|https://github.com/apache/maven-resolver/blob/maven-resolver-1.4.0/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/NearestVersionSelector.java#L158]
tries to throw UnsolvableVersionConflictExceptoin. However, before throwing
the exception PathRecordingDependencyVisitor visits nodes in the dependency
graph and the graph contains a cycle. The visitor goes to infinite recursion in
visiting the cyclic path, resulting in StackOverflowError.
{code:java}
private UnsolvableVersionConflictException newFailure( final ConflictContext
context )
{
...
PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor(
filter );
context.getRoot().accept( visitor );
return new UnsolvableVersionConflictException( visitor.getPaths() );
}{code}
The cycle in the graph consists of module-a and module-b as illustrated below:
{code:java}
module-c:1.0.0
+- module-b:2.0.0
+- module-a:1.0.0
+- module-b:0.0.1
+- module-b:1.0.0
| +- module-a:1.0.0
| +- module-b:0.0.1
| +- module-b:1.0.0
...{code}
was:
Maven throws StackOverflowError when version ranges are unsolvable and the
dependency graph contains a cycle.
{code:java}
[INFO] --------------------------< suztomo:module-c >--------------------------
[INFO] Building module-c 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.406 s
[INFO] Finished at: 2019-08-16T12:10:30-04:00
[INFO] ------------------------------------------------------------------------
...
Exception in thread "main" java.lang.StackOverflowError
at
org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:341)
at
org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
at
org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
at
org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
at
org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
at
org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
...(omitting many lines)...
{code}
h1. Example
Example project to reproduce the issue:
[https://github.com/suztomo/maven-cyclic-dependency-with-range]
h1. Diagnosis
In the example above, because of a version conflict on grpc-core (1.21.0 v.s.
1.16.1),
[org.eclipse.aether.util.graph.transformer.NearestVersionSelector.newFailure|https://github.com/apache/maven-resolver/blob/maven-resolver-1.4.0/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/NearestVersionSelector.java#L158]
tries to throw UnsolvableVersionConflictExceptoin. However, before throwing
the exception PathRecordingDependencyVisitor visits nodes in the dependency
graph and the graph contains a cycle. The visitor goes to infinite recursion in
visiting the cyclic path, resulting in StackOverflowError.
{code:java}
private UnsolvableVersionConflictException newFailure( final ConflictContext
context )
{
...
PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor(
filter );
context.getRoot().accept( visitor );
return new UnsolvableVersionConflictException( visitor.getPaths() );
}{code}
The cycle in the graph consists of module-a and module-b as illustrated below:
{code:java}
module-c:1.0.0
+- module-b:2.0.0
+- module-a:1.0.0
+- module-b:0.0.1
+- module-b:1.0.0
| +- module-a:1.0.0
| +- module-b:0.0.1
| +- module-b:1.0.0
...{code}
> StackOverflowError when version ranges are unsolvable unsolvable and graph
> contains a cycle
> -------------------------------------------------------------------------------------------
>
> Key: MNG-6737
> URL: https://issues.apache.org/jira/browse/MNG-6737
> Project: Maven
> Issue Type: Improvement
> Affects Versions: 3.6.1
> Reporter: Tomo Suzuki
> Priority: Major
>
> Maven throws StackOverflowError when version ranges are unsolvable and the
> dependency graph contains a cycle.
> {code:java}
> $ mvn install
> ...
> [INFO] --------------------------< suztomo:module-c
> >--------------------------
> [INFO] Building module-c 1.0
> [INFO] --------------------------------[ jar
> ]---------------------------------
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 0.406 s
> [INFO] Finished at: 2019-08-16T12:10:30-04:00
> [INFO]
> ------------------------------------------------------------------------
> ...
> Exception in thread "main" java.lang.StackOverflowError
> at
> org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:341)
> at
> org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
> at
> org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
> at
> org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
> at
> org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
> at
> org.eclipse.aether.graph.DefaultDependencyNode.accept(DefaultDependencyNode.java:345)
> ...(omitting many lines)...
> {code}
> h1. Example
> Example project to reproduce the issue:
> [https://github.com/suztomo/maven-cyclic-dependency-with-range]
> h1. Diagnosis
> In the example above, because of a version conflict on grpc-core (1.21.0 v.s.
> 1.16.1),
> [org.eclipse.aether.util.graph.transformer.NearestVersionSelector.newFailure|https://github.com/apache/maven-resolver/blob/maven-resolver-1.4.0/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/NearestVersionSelector.java#L158]
> tries to throw UnsolvableVersionConflictExceptoin. However, before throwing
> the exception PathRecordingDependencyVisitor visits nodes in the dependency
> graph and the graph contains a cycle. The visitor goes to infinite recursion
> in visiting the cyclic path, resulting in StackOverflowError.
>
> {code:java}
> private UnsolvableVersionConflictException newFailure( final ConflictContext
> context )
> {
> ...
> PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor(
> filter );
> context.getRoot().accept( visitor );
> return new UnsolvableVersionConflictException( visitor.getPaths() );
> }{code}
>
> The cycle in the graph consists of module-a and module-b as illustrated below:
> {code:java}
> module-c:1.0.0
> +- module-b:2.0.0
> +- module-a:1.0.0
> +- module-b:0.0.1
> +- module-b:1.0.0
> | +- module-a:1.0.0
> | +- module-b:0.0.1
> | +- module-b:1.0.0
> ...{code}
>
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)