Skip to content

8382485: ArrayIndexOutOfBoundsException was hiding in ClhsdbPrintAll.jtr#30808

Closed
YaSuenag wants to merge 2 commits intoopenjdk:masterfrom
YaSuenag:JDK-8382485
Closed

8382485: ArrayIndexOutOfBoundsException was hiding in ClhsdbPrintAll.jtr#30808
YaSuenag wants to merge 2 commits intoopenjdk:masterfrom
YaSuenag:JDK-8382485

Conversation

@YaSuenag
Copy link
Copy Markdown
Member

@YaSuenag YaSuenag commented Apr 18, 2026

ArrayIndexOutOfBoundsException as following was hiding in ClhsdbPrintAll.java. See attached .jtr file in JBS.

java.lang.ArrayIndexOutOfBoundsException: 7 6
at jdk.hotspot.agent/sun.jvm.hotspot.oops.ResolvedMethodArray.getAt(ResolvedMethodArray.java:60)
at jdk.hotspot.agent/sun.jvm.hotspot.oops.ConstantPoolCache.getMethodEntryAt(ConstantPoolCache.java:99)
at jdk.hotspot.agent/sun.jvm.hotspot.interpreter.BytecodeWithCPIndex.indexForFieldOrMethod(BytecodeWithCPIndex.java:57)
at jdk.hotspot.agent/sun.jvm.hotspot.interpreter.BytecodeGetPut.toString(BytecodeGetPut.java:58)
at jdk.hotspot.agent/sun.jvm.hotspot.ui.classbrowser.HTMLGenerator$1.visit(HTMLGenerator.java:685)
at jdk.hotspot.agent/sun.jvm.hotspot.interpreter.BytecodeDisassembler.decode(BytecodeDisassembler.java:156)
at jdk.hotspot.agent/sun.jvm.hotspot.ui.classbrowser.HTMLGenerator.genHTML(HTMLGenerator.java:659)
at jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor$18$1.visit(CommandProcessor.java:876)
at jdk.hotspot.agent/sun.jvm.hotspot.classfile.ClassLoaderData.classesDo(ClassLoaderData.java:113)
at jdk.hotspot.agent/sun.jvm.hotspot.classfile.ClassLoaderDataGraph.classesDo(ClassLoaderDataGraph.java:84)
at jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor$18.doit(CommandProcessor.java:869)
at jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor.executeCommand(CommandProcessor.java:2051)
at jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor.executeCommand(CommandProcessor.java:2021)
at jdk.hotspot.agent/sun.jvm.hotspot.CommandProcessor.run(CommandProcessor.java:1892)
at jdk.hotspot.agent/sun.jvm.hotspot.CLHSDB.run(CLHSDB.java:113)
at jdk.hotspot.agent/sun.jvm.hotspot.CLHSDB.main(CLHSDB.java:45)
at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runCLHSDB(SALauncher.java:285)
at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:507)

AFAICS all of failures are caused by getfield bytecode. We can see it in javap, but in SA, another bytecode values (e.g. "234") were detected. Thus getfield would not be handled as field operation at folloing code in BytecodeWithCPIndex.java, eventually the exception was thrown.

     if (cpCache == null) {
        return cpCacheIndex;
     } else if (code() == Bytecodes._invokedynamic) {
        return cpCache.getIndyEntryAt(cpCacheIndex).getConstantPoolIndex();
     } else if (Bytecodes.isFieldCode(code())) {
        return cpCache.getFieldEntryAt(cpCacheIndex).getConstantPoolIndex();
     } else {
        return cpCache.getMethodEntryAt(cpCacheIndex).getConstantPoolIndex();
     }

In Bytecodes.java, following values should be handled as field operations. Bytecodes.isFieldCode() should identify them.

  public static final int _getstatic = 178; // 0xb2
  public static final int _putstatic = 179; // 0xb3
  public static final int _getfield = 180; // 0xb4
  public static final int _putfield = 181; // 0xb5

    :

  public static final int number_of_java_codes = 203;

  // JVM bytecodes
  public static final int _fast_agetfield = number_of_java_codes;
  public static final int _fast_bgetfield = 204;
  public static final int _fast_cgetfield = 205;
  public static final int _fast_dgetfield = 206;
  public static final int _fast_fgetfield = 207;
  public static final int _fast_igetfield = 208;
  public static final int _fast_lgetfield = 209;
  public static final int _fast_sgetfield = 210;
  public static final int _fast_aputfield = 211;
  public static final int _fast_bputfield = 212;
  public static final int _fast_zputfield = 213;
  public static final int _fast_cputfield = 214;
  public static final int _fast_dputfield = 215;
  public static final int _fast_fputfield = 216;
  public static final int _fast_iputfield = 217;
  public static final int _fast_lputfield = 218;
  public static final int _fast_sputfield = 219;

    :

  // Bytecodes rewritten at CDS dump time
  public static final int _nofast_getfield = 234;
  public static final int _nofast_putfield = 235;

Maybe this is long-standing bug because the exception could not be caught jtreg tests, thus I updated testcase to check stderr. But ClhsdbDumpheap.java and ClhsdbJhisto.java would ignore this because they prints message into stderr or checks strings in stderr.



Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8382485: ArrayIndexOutOfBoundsException was hiding in ClhsdbPrintAll.jtr (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30808/head:pull/30808
$ git checkout pull/30808

Update a local copy of the PR:
$ git checkout pull/30808
$ git pull https://git.openjdk.org/jdk.git pull/30808/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30808

View PR using the GUI difftool:
$ git pr show -t 30808

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30808.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Apr 18, 2026

👋 Welcome back ysuenaga! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Apr 18, 2026

@YaSuenag This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8382485: ArrayIndexOutOfBoundsException was hiding in ClhsdbPrintAll.jtr

Reviewed-by: cjplummer, kevinw

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 110 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk Bot added the serviceability serviceability-dev@openjdk.org label Apr 18, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Apr 18, 2026

@YaSuenag The following label will be automatically applied to this pull request:

  • serviceability

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk Bot added the rfr Pull request is ready for review label Apr 18, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented Apr 18, 2026

Webrevs

@YaSuenag
Copy link
Copy Markdown
Member Author

Changes in ClhsdbLauncher.java‎ causes new error in mixed jstack tests on Alpine, but it would be fixed in #30815.

Comment on lines +155 to +157
if (!allowStderrOutput) {
oa.stderrShouldBeEmptyIgnoreVMWarnings();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be careful here. I think the reason for by default allowing stderr output is because it can sometimes appear, but is not necessarily indicative of bug. For example, sometimes during the stack dump an active thread can produce an exception because it is not in a consistent state, but the thread we care about (like SteadyStateThread) produces what we are looking for, so the test should pass. I worry that this change is going to produce a lot of intermittent failures.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed the thread might have inconsistent state because they would be stopped by signal or ptrace().
So is it better to check *Exception: and *Error: in stderr?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that is what my concern is. We can see exceptions on stderr that we want to ignore.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, so should I remove changes for the test from PR? I think it is difficult to choose exceptions/errors what we can ignore.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted changes for testcode. I think it is reasonable so far.
@plummercj Can you review?

Copy link
Copy Markdown
Contributor

@plummercj plummercj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for the fix!

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Apr 24, 2026
@YaSuenag
Copy link
Copy Markdown
Member Author

/integrate

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Apr 24, 2026

Going to push as commit df8a940.
Since your change was applied there have been 117 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk Bot added the integrated Pull request has been integrated label Apr 24, 2026
@openjdk openjdk Bot closed this Apr 24, 2026
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 24, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Apr 24, 2026

@YaSuenag Pushed as commit df8a940.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@YaSuenag YaSuenag deleted the JDK-8382485 branch April 25, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

3 participants