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

NPE during expiration check #842

Closed
jorgheymans opened this issue May 8, 2023 · 1 comment
Closed

NPE during expiration check #842

jorgheymans opened this issue May 8, 2023 · 1 comment
Assignees
Milestone

Comments

@jorgheymans
Copy link

jorgheymans commented May 8, 2023

Just encountered this on a maven build (regular clean install, small single module project)

Apache Maven Daemon (mvnd) 1.0-m6 linux-amd64 native client (47d4c6b9c399079d91312bb8ae35d1d76e7fd97a)
Terminal: org.jline.terminal.impl.PosixSysTerminal with pty org.jline.terminal.impl.jansi.linux.LinuxNativePty
Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
Maven home: /home/user/.sdkman/candidates/mvnd/1.0-m6-m39/mvn
Java version: 11.0.18, vendor: IBM Corporation, runtime: /home/user/.sdkman/candidates/java/11.0.18-sem
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.19.0-41-generic", arch: "amd64", family: "unix"
11:42:54.378 D Expiration check running
11:42:54.378 E Problem in daemon expiration check
java.lang.NullPointerException: null
	at org.mvndaemon.mvnd.daemon.DaemonMemoryStatus.isTrashing(DaemonMemoryStatus.java:163)
	at org.mvndaemon.mvnd.daemon.DaemonExpiration.lambda$gcTrashing$0(DaemonExpiration.java:75)
	at org.mvndaemon.mvnd.daemon.DaemonExpiration.lambda$any$9(DaemonExpiration.java:200)
	at org.mvndaemon.mvnd.daemon.DaemonExpiration.lambda$any$9(DaemonExpiration.java:200)
	at org.mvndaemon.mvnd.daemon.Server.expirationCheck(Server.java:321)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:839)

daemon log:

Starting daemon process: id = ddb5dd8d, workingDir = /home/user/src/auditing, daemonArgs: /home/user/.sdkman/candidates/java/11.0.18-sem/bin/java -classpath /home/user/.sdkman/candidates/mvnd/1.0-m6-m39/mvn/boot/plexus-classworlds-2.6.0.jar -javaagent:/home/user/.sdkman/candidates/mvnd/1.0-m6-m39/mvn/lib/mvnd/mvnd-agent-1.0-m6.jar -client -XX:+ClassRelationshipVerifier -Dmvnd.home=/home/user/.sdkman/candidates/mvnd/1.0-m6-m39 -Dmaven.home=/home/user/.sdkman/candidates/mvnd/1.0-m6-m39/mvn -Dmaven.conf=/home/user/.sdkman/candidates/mvnd/1.0-m6-m39/mvn/conf -Dclassworlds.conf=/home/user/.sdkman/candidates/mvnd/1.0-m6-m39/bin/mvnd-daemon.conf -Dmvnd.java.home=/home/user/.sdkman/candidates/java/11.0.18-sem -Dlogback.configurationFile=/home/user/.sdkman/candidates/mvnd/1.0-m6-m39/mvn/conf/logging/logback-daemon.xml -Dmvnd.id=ddb5dd8d -Dmvnd.daemonStorage=/home/user/.m2/mvnd/registry/1.0-m6 -Dmvnd.registry=/home/user/.m2/mvnd/registry/1.0-m6/registry.bin -Dmvnd.socketFamily=inet -Dmvnd.home=/home/user/.sdkman/candidates/mvnd/1.0-m6-m39 -Djdk.java.options=--add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-opens java.base/sun.nio.fs=ALL-UNNAMED -Dmvnd.noDaemon=false -Dmvnd.debug=false -Dmvnd.debug.address=8000 -Dmvnd.idleTimeout=3h -Dmvnd.keepAlive=100ms -Dmvnd.extClasspath= -Dmvnd.coreExtensions= -Dmvnd.jvmArgs=-client -XX:+ClassRelationshipVerifier -Dmvnd.enableAssertions=false -Dmvnd.expirationCheckDelay=10s -Dmvnd.duplicateDaemonGracePeriod=10s -Dmvnd.socketFamily=inet org.codehaus.plexus.classworlds.launcher.LauncherNOTE: Picked up JDK_JAVA_OPTIONS: --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-opens java.base/sun.nio.fs=ALL-UNNAMED

It's not really reproducable, subsequent builds run fine.

@ppalaga
Copy link
Contributor

ppalaga commented May 8, 2023

First a null strategy is a legit outcome of the code around here

for (GcStrategy testStrategy : GcStrategy.values()) {
garbageCollector = garbageCollectors.stream()
.filter(gc -> gc.getName().equals(testStrategy.garbageCollector))
.findFirst()
.orElse(null);
heapMemoryPoolMXBean = memoryPoolMXBeans.stream()
.filter(mp -> mp.getName().equals(testStrategy.heapMemoryPool))
.findFirst()
.orElse(null);
nonHeapMemoryPoolMXBean = memoryPoolMXBeans.stream()
.filter(mp -> mp.getName().equals(testStrategy.nonHeapMemoryPool))
.findFirst()
.orElse(null);
if (garbageCollector != null && heapMemoryPoolMXBean != null && nonHeapMemoryPoolMXBean != null) {
strategy = testStrategy;
break;
}
}
if (strategy != null) {
this.strategy = strategy;
this.garbageCollectorMXBean = garbageCollector;
this.heapMemoryPoolMXBean = heapMemoryPoolMXBean;
this.nonHeapMemoryPoolMXBean = nonHeapMemoryPoolMXBean;
this.clock = Clock.systemUTC();
executor.scheduleAtFixedRate(this::gatherData, 1, 1, TimeUnit.SECONDS);
} else {
this.strategy = null;
this.garbageCollectorMXBean = null;
this.heapMemoryPoolMXBean = null;
this.nonHeapMemoryPoolMXBean = null;
this.clock = null;
}
}

So isTrashing, isHeapSpaceExhausted & friends should not assume strategy being non-null

public boolean isTrashing() {
if (strategy.heapUsageThreshold != 0 && strategy.thrashingThreshold != 0) {
GcStats stats = heapStats();
return stats != null
&& stats.usedPercent >= strategy.heapUsageThreshold
&& stats.gcRate >= strategy.thrashingThreshold;
} else {
return false;
}
}

Would you mind sending a PR?

Second, I wonder what GcStrategy params would catch your JVM Java version: 11.0.18, vendor: IBM Corporation, runtime: /home/user/.sdkman/candidates/java/11.0.18-sem?

ORACLE_PARALLEL_CMS("PS Old Gen", "Metaspace", "PS MarkSweep", 1.2, 80, 80, 5.0),
ORACLE_6_CMS("CMS Old Gen", "Metaspace", "ConcurrentMarkSweep", 1.2, 80, 80, 5.0),
ORACLE_SERIAL("Tenured Gen", "Metaspace", "MarkSweepCompact", 1.2, 80, 80, 5.0),
ORACLE_G1("G1 Old Gen", "Metaspace", "G1 Old Generation", 0.4, 75, 80, 2.0),
IBM_ALL("Java heap", "Not Used", "MarkSweepCompact", 0.8, 70, -1, 6.0);

gnodet added a commit to gnodet/mvnd that referenced this issue May 11, 2023
@gnodet gnodet added this to the 1.0-m7 milestone May 11, 2023
@gnodet gnodet self-assigned this May 16, 2023
gnodet added a commit to gnodet/mvnd that referenced this issue May 17, 2023
@gnodet gnodet closed this as completed in 6a3448d May 17, 2023
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

3 participants