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

display-plugin-updates goal hang #354

Closed
onacit opened this issue Jun 26, 2019 · 13 comments
Closed

display-plugin-updates goal hang #354

onacit opened this issue Jun 26, 2019 · 13 comments

Comments

@onacit
Copy link

onacit commented Jun 26, 2019

I just found the display-plugin-updates goal hang.

I got following output with -X option.

[DEBUG] super-pom version map
    org.apache.maven.plugins:maven-clean-plugin:2.5
    org.apache.maven.plugins:maven-resources-plugin:2.6
    org.apache.maven.plugins:maven-jar-plugin:2.4
    org.apache.maven.plugins:maven-compiler-plugin:3.1
    org.apache.maven.plugins:maven-surefire-plugin:2.12.4
    org.apache.maven.plugins:maven-install-plugin:2.4
    org.apache.maven.plugins:maven-deploy-plugin:2.7
    org.apache.maven.plugins:maven-site-plugin:3.3
    org.apache.maven.plugins:maven-antrun-plugin:1.3
    org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5
    org.apache.maven.plugins:maven-dependency-plugin:2.8
    org.apache.maven.plugins:maven-release-plugin:2.5.3
    org.apache.maven.plugins:maven-source-plugin:null
    org.apache.maven.plugins:maven-javadoc-plugin:null
[DEBUG] parent version map
    org.apache.maven.plugins:maven-gpg-plugin:1.6
    org.apache.maven.plugins:maven-release-plugin:2.5.3
    org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8
    org.apache.maven.plugins:maven-source-plugin:3.0.1
    org.apache.maven.plugins:maven-javadoc-plugin:3.1.0
    org.codehaus.mojo:tidy-maven-plugin:1.1.0
    org.codehaus.mojo:versions-maven-plugin:2.7
    org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M2
[DEBUG] aggregate version map
    org.apache.maven.plugins:maven-release-plugin:2.5.3
    org.apache.maven.plugins:maven-site-plugin:3.3
    org.apache.maven.plugins:maven-source-plugin:3.0.1
    org.apache.maven.plugins:maven-javadoc-plugin:3.1.0
    org.apache.maven.plugins:maven-resources-plugin:2.6
    org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5
    org.apache.maven.plugins:maven-antrun-plugin:1.3
    org.apache.maven.plugins:maven-gpg-plugin:1.6
    org.apache.maven.plugins:maven-compiler-plugin:3.1
    org.apache.maven.plugins:maven-surefire-plugin:2.12.4
    org.apache.maven.plugins:maven-jar-plugin:2.4
    org.apache.maven.plugins:maven-clean-plugin:2.5
    org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8
    org.apache.maven.plugins:maven-install-plugin:2.4
    org.apache.maven.plugins:maven-dependency-plugin:2.8
    org.apache.maven.plugins:maven-deploy-plugin:2.7
    org.codehaus.mojo:tidy-maven-plugin:1.1.0
    org.codehaus.mojo:versions-maven-plugin:2.7
    org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M2
[DEBUG] final aggregate version map
    org.apache.maven.plugins:maven-release-plugin:2.5.3
    org.apache.maven.plugins:maven-site-plugin:3.3
    org.apache.maven.plugins:maven-source-plugin:3.0.1
    org.apache.maven.plugins:maven-javadoc-plugin:3.1.0
    org.apache.maven.plugins:maven-resources-plugin:2.6
    org.apache.maven.plugins:maven-gpg-plugin:1.6
    org.apache.maven.plugins:maven-compiler-plugin:3.1
    org.apache.maven.plugins:maven-surefire-plugin:2.12.4
    org.apache.maven.plugins:maven-clean-plugin:2.5
    org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8
    org.apache.maven.plugins:maven-install-plugin:2.4
    org.apache.maven.plugins:maven-deploy-plugin:2.7
    org.codehaus.mojo:tidy-maven-plugin:1.1.0

No more output is coming.

Here comes my environment.

Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T04:00:29+09:00)
Maven home: /usr/local/Cellar/maven/3.6.1/libexec
Java version: 1.8.0_211, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre
Default locale: en_KR, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.5", arch: "x86_64", family: "mac"
@hfatela
Copy link

hfatela commented Aug 2, 2019

Hit on the same problem. Downgrading the maven version to 3.5.4 solves this issue.

@kingoleg
Copy link

The same issue in mvn 3.6.2

@onacit
Copy link
Author

onacit commented Nov 22, 2019

FYI, I still facing this problem with this pom.

@tomgl
Copy link

tomgl commented Dec 23, 2019

I've got the same (?) issue, with Maven 3.6.3 and versions-maven-plugin 2.7.
After some trial and error, I been able to write this minimal pom.xml to exhibit the issue:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>blah</groupId>
	<artifactId>blah</artifactId>
	<version>1.0</version>
	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-resources-plugin</artifactId>
					<version>3.1.0</version>
				</plugin>
			</plugins>
		</pluginManagement>
		<plugins>
<!-- uncommenting this block avoids the bug -->
<!--
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
			</plugin>
-->
		</plugins>
	</build>
	<profiles>
		<profile>
			<id>something</id>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-resources-plugin</artifactId>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>

It seems to boil down to the case of a plugin which is only included by an active profile, without being part of the default build. Having this plugin's version set in pluginManagement, like above, is not a necessary condition to trigger the bug.

@onacit: the pom.xml you've linked to seems similar in it's usage of the maven-shade-plugin: its version is in pluginManagement, but appart from that, it is only referenced in the (active by default) shade profile.

When mvn versions:display-plugin-updates hangs, I see one CPU spinning 100%, and if I grab a few stacktraces they all are in StringSearchModelInterpolator.interpolate:

  • example 1:
"main" #1 prio=5 os_prio=0 tid=0x00007f4a2800b000 nid=0x3a18 runnable [0x00007f4a2eae3000]
   java.lang.Thread.State: RUNNABLE
	at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.traverseObjectWithParents(StringSearchModelInterpolator.java:345)
	at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.run(StringSearchModelInterpolator.java:140)
	at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.run(StringSearchModelInterpolator.java:107)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.apache.maven.project.interpolation.StringSearchModelInterpolator.interpolateObject(StringSearchModelInterpolator.java:86)
	at org.apache.maven.project.interpolation.StringSearchModelInterpolator.interpolate(StringSearchModelInterpolator.java:68)
	at org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.getProjectPlugins(DisplayPluginUpdatesMojo.java:1486)
	at org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.execute(DisplayPluginUpdatesMojo.java:381)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
...
  • example 2:
"main" #1 prio=5 os_prio=0 tid=0x00007f4a2800b000 nid=0x3a18 runnable [0x00007f4a2eae3000]
   java.lang.Thread.State: RUNNABLE
	at java.util.WeakHashMap.getTable(WeakHashMap.java:350)
	at java.util.WeakHashMap.getEntry(WeakHashMap.java:427)
	at java.util.WeakHashMap.containsKey(WeakHashMap.java:417)
	at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.isQualifiedForInterpolation(StringSearchModelInterpolator.java:356)
	at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.traverseObjectWithParents(StringSearchModelInterpolator.java:177)
	at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.run(StringSearchModelInterpolator.java:140)
	at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.run(StringSearchModelInterpolator.java:107)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.apache.maven.project.interpolation.StringSearchModelInterpolator.interpolateObject(StringSearchModelInterpolator.java:86)
	at org.apache.maven.project.interpolation.StringSearchModelInterpolator.interpolate(StringSearchModelInterpolator.java:68)
	at org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.getProjectPlugins(DisplayPluginUpdatesMojo.java:1486)
	at org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.execute(DisplayPluginUpdatesMojo.java:381)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
...

I'm not really able to debug this further, but just one last note: googling for StringSearchModelInterpolator suggests it has been superseded in Maven 3.6.x, by StringVisitorModelInterpolator: MNG-6799 (so I don't even understand why it appears in my stacktraces, but I really don't know Maven internals at all, just mentioning it...)

@bobfields
Copy link

With Java11 on Windows 10: versions plugin 2.8.1 display-plugin-updates is successful with maven 3.6.0 (and earlier), and unsuccessful (hangs) with maven 3.6.1 (and later). maven 3.6.1 was released on 2019-09-03, changes: http://maven.apache.org/docs/3.6.1/release-notes.html

@jonesbusy
Copy link

Same issue here with maven 3.8.1 and versions-maven-plugin 2.7

@frank-montyne
Copy link

Same issue here with maven 3.8.1 and versions-maven-plugin 2.7
Can someone look at htis problem please. Maven 3.6.0 is the last usable version to avoid this problem

@filnet
Copy link

filnet commented Oct 19, 2021

Same issue with maven 3.8.3 and versions-maven-plugin 2.8.1.

Stack trace:

"main" #1 prio=5 os_prio=0 tid=0x00000000022db000 nid=0x2a3c runnable [0x000000000268c000]
   java.lang.Thread.State: RUNNABLE
        at java.util.WeakHashMap.getTable(WeakHashMap.java:350)
        at java.util.WeakHashMap.get(WeakHashMap.java:397)
        at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.isQualifiedForInterpolation(StringSearchModelInterpolator.java:361)
        at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.traverseObjectWithParents(StringSearchModelInterpolator.java:177)
        at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.run(StringSearchModelInterpolator.java:140)
        at org.apache.maven.project.interpolation.StringSearchModelInterpolator$InterpolateObjectAction.run(StringSearchModelInterpolator.java:107)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.apache.maven.project.interpolation.StringSearchModelInterpolator.interpolateObject(StringSearchModelInterpolator.java:86)
        at org.apache.maven.project.interpolation.StringSearchModelInterpolator.interpolate(StringSearchModelInterpolator.java:68)
        at org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.getProjectPlugins(DisplayPluginUpdatesMojo.java:1492)
        at org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.execute(DisplayPluginUpdatesMojo.java:379)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:972)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

@delanym
Copy link

delanym commented Nov 22, 2021

Still an issue from 3.8.4 wrapper

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Sep 3, 2022

I'm not really able to debug this further, but just one last note: googling for StringSearchModelInterpolator suggests it has been superseded in Maven 3.6.x, by StringVisitorModelInterpolator: MNG-6799 (so I don't even understand why it appears in my stacktraces, but I really don't know Maven internals at all, just mentioning it...)

That's because there are two classes with the same simple class name:

  • org.apache.maven.project.interpolation.StringSearchModelInterpolator (maven-compat, for maven 2 compatibility)
  • org.apache.maven.model.interpolation.StringSearchModelInterpolator (maven-model-builder, transitive dependency via maven-core)

MNG-6799 is about the latter while the stack traces shown in this ticket show the former.

Strangely enough, when I'm trying to reproduce it, StringVisitorModelInterporator gets injected as modelInterpolator, so, the component from maven-model-builder. How is the Maven 2 compatibility component being picked?

PR #549 changed the model interpolator to the non-deprecated one. Chances are that the error is not present in the new one. However, I'm investigating why it occurred with the old one in the first place.

The old model interpolator implements recursion using its own stack (interpolationTarget):

while ( !interpolationTargets.isEmpty() )
{
    Object obj = interpolationTargets.removeFirst();

    traverseObjectWithParents( obj.getClass(), obj );
}

The above code removes the currently processed element from interpolationTarget, just like a function call would do, but then places newly found elements to be processed into that collection.

This risks an infinite recursion loop if the analysed model contains cycles. So, it's possible that the function is fed a model with cycles in it. But it's highly possible that the new implementation is already protected against that.

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Sep 3, 2022

Verified that the PR #549 fixes the problem. I have verified that it did occur with the commit right before it (619d36c) and it is fixed with commit 82c6e1c.

The fix landed in versions-maven-plugin 2.10.0.

@jarmoniuk
Copy link
Contributor

@slachiewicz the issue can be closed (resolved in 2.10.0)

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Sep 4, 2022

And by the way, should anyone be interested in getting to the root cause of that issue (which does not lie within this project, but in maven-compat), the model (also built by maven and not the plugin) contains circular dependencies in InputLocation/InputSource metadata for the model elements. The simplest fix for that in maven-compat would be to skip interpolating InputLocation altogether. But, as I said, that's not within this plugin.

Here's a branch I created based on the 2.9.1-SNAPSHOT just before the fix, to get to the root cause of the issue, with a build.log in the it directory containing the trace of the interpolation.

https://github.com/ajarmoniuk/versions-maven-plugin/tree/issue-354-not-working-revision

To execute the test:

mvn -P run-its clean verify -DskipTests -Dcheckstyle.skip -Dinvoker.test=it-display-plugin-updates-013*

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