JDK-8211923 : [Testbug] serviceability/sa/ClhsdbFindPC.java ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc-agent
  • Affected Version: 12
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2018-10-09
  • Updated: 2021-07-28
  • Resolved: 2020-04-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
Test failed in tier 1 of the CI:

Attaching to process 14324, please wait...
Warning: Nashorn engine is planned to be removed from a future JDK release
javax.script.ScriptException: TypeError: sapkg.runtime.VM.getVM is not a function in sa.js at line number 54
javax.script.ScriptException: TypeError: sapkg.runtime.VM.getVM is not a function in sa.js at line number 54
java.lang.NullPointerException
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:83)
	at jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor$24.doit(CommandProcessor.java:1066)
	at jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor.executeCommand(CommandProcessor.java:1974)
	at jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor.executeCommand(CommandProcessor.java:1944)
	at jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor.run(CommandProcessor.java:1824)
	at jdk.hotspot.agent/sun.jvm.hotspot.CLHSDB.run(CLHSDB.java:99)
	at jdk.hotspot.agent/sun.jvm.hotspot.CLHSDB.main(CLHSDB.java:40)
	at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runCLHSDB(SALauncher.java:191)
	at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:439)
 LingeredApp stdout: [];
 LingeredApp stderr: []
 LingeredApp exitValue = 0
java.lang.RuntimeException: Test ERROR java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
	at ClhsdbFindPC.testFindPC(ClhsdbFindPC.java:95)
	at ClhsdbFindPC.main(ClhsdbFindPC.java:103)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
	at ClhsdbFindPC.testFindPC(ClhsdbFindPC.java:69)
	... 7 more

Something has gone with regards to running the test, but the test logic is not robust enough. We have:

           // Output could be null if the test was skipped due to
            // attach permission issues.
            if (output != null) {
                String cmdStr = null;
                String[] parts = output.split("LingeredApp.main");
                String[] tokens = parts[1].split(" ");

but if output is not null, but doesn't contain LingeredApp.main then we don't have two parts and so parts[1] throws ArrayIndexOutOfBoundException
Comments
This is a duplicate of JDK-8243455.
23-04-2020

The issue is the same as JDK-8240781 and JDK-8242411. The stack trace for the main thread is missing: "main" #1 prio=5 tid=0x00007f981e00a800 nid=0x2103 runnable [0x0000000000000000] java.lang.Thread.State: RUNNABLE JavaThread state: _thread_in_java So output.split("LingeredApp.main") doesn't do any splitting, and indexing into the 2nd element of the returned array produces the AIOOBE.
15-04-2020

I'm not sure why the 'tier1' label was removed since this test has failed in tier1 testing. I've restored the label.
10-03-2020

Here's the current version of the code in question: // Run 'jstack -v' command to get the pc List<String> cmds = List.of("jstack -v"); String output = test.run(theApp.getPid(), cmds, null, null); // Test the 'findpc' command passing in the pc obtained from // the 'jstack -v' command cmds = new ArrayList<String>(); // Output could be null if the test was skipped due to // attach permission issues. if (output != null) { String cmdStr = null; String[] parts = output.split("LingeredAppWithTrivialMain.main"); String[] tokens = parts[1].split(" "); for (String token : tokens) { if (token.contains("pc")) { String[] address = token.split("="); // address[1] represents the address of the Method cmdStr = "findpc " + address[1].replace(",",""); cmds.add(cmdStr); break; } } If the "jstack -v" output is missing a section for "LingeredAppWithTrivialMain.main", then the address[1] reference will fail due to: java.lang.RuntimeException: Test ERROR java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1 In other words, the test code assumes that the "jstack -v" works and if it doesn't, then we get a less than useful failure mode. The above ArrayIndexOutOfBoundsException does nothing for telling us why there is no section for "LingeredAppWithTrivialMain.main" in the "jstack -v" output. Please treat this bug as the test issue it is. The reason for the "jstack -v" failure is NOT the point of this bug.
16-12-2019

I think this bug is not a duplicate of JDK-8196969. We're still seeing test failures in Adhoc Mach5 jobs due to the issue that David described. I'm reopening the bug.
16-12-2019

This looks like a duplicate of JDK-8196969. This would not be a test bug.
13-12-2018

clhsdb jstack command gives an error "Error occurred during stack walking:". It is not clear from logs, why the stack walking failed. I will do the following modifications to the testcase: 1. If jstack output does not contain "LingeredApp.main", fail the test. 2. The test is testing both -Xcomp and -Xint options. I have changed the order of the test and made -Xint first. Currently the failure is in -Xcomp. Changing the order tells us (in future failures) if the interpretted mode passed or not. "main" #1 prio=5 tid=0x0000008de4f75800 nid=0x4ddc runnable [0x0000000000000000] java.lang.Thread.State: RUNNABLE JavaThread state: _thread_in_java - sun.nio.fs.AbstractFileSystemProvider.exists(java.nio.file.Path) @bci=0, line=151, pc=0x0000008ded83b547, Method*=0x00000008002d31c0 (Compiled frame; information may be imprecise) Error occurred during stack walking:
12-12-2018