JDK-8319828 : runtime/NMT/VirtualAllocCommitMerge.java may fail if mixing interpreted and compiled native invocations
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 11,17,21,22
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-11-09
  • Updated: 2024-01-09
  • Resolved: 2023-11-10
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.
JDK 21 JDK 22
21.0.2Fixed 22 b24Fixed
Related Reports
Relates :  
Description
We saw this problem on s390x, but it was easy to reproduce on x64.

The test creates adjacent commit sections via NMTCommitMemory(), and then expects them to show up as merged sections in the NMT report.

That sometimes fails, as here:

```
Execution failed: `main' threw exception: java.lang.RuntimeException: '[0x[0]3ff859fc000 - 0x[0]*3ff85a5c000] committed 384KB from.' missing from stdout/stderr
```
and the relevant snippet in the NMT report was:

```
[0x000003ff859fc000 - 0x000003ff85dfc000] reserved 4096KB for Test from
    [0x000003ffb4ad2a58] WB_NMTReserveMemory+0xc0
    [0x000003ff9bf43344]

    [0x000003ff859fc000 - 0x000003ff85a1c000] committed 128KB from
            [0x000003ffb4ad288c] WB_NMTCommitMemory+0xc4

    [0x000003ff85a1c000 - 0x000003ff85a5c000] committed 256KB from
            [0x000003ffb4ad288c] WB_NMTCommitMemory+0xc4
            [0x000003ff9bf43344]
```

Note that it shows two adjacent commit sections, one 128k, one 256k, that the test expected to show up as one merged section of 384k.

The reason for this is that the first invocation of NMTCommitMemory happened interpreted, the second one compiled. That alters the stack: in the first case we have an Interpreter Codelet on the stack, in the second case the compiled nmethod. See here an annotated stack:

```
[0x00007fceb0147000 - 0x00007fceb0547000] reserved 4096KB for Test from
    [0x00007fcef3beccd5] WB_NMTReserveMemory+0xa5
    [0x00007fcedb92bbce]0x00007fcedb92bbce is at code_begin+1806 in an Interpreter codelet

	[0x00007fceb0147000 - 0x00007fceb0167000] committed 128KB from
            [0x00007fcef3bed098] WB_NMTCommitMemory+0xa8
            [0x00007fcedc0901a1]0x00007fcedc0901a1 is at entry_point+225 in (nmethod*)0x00007fcedc08ff10

	[0x00007fceb0167000 - 0x00007fceb01a7000] committed 256KB from
            [0x00007fcef3bed098] WB_NMTCommitMemory+0xa8
            [0x00007fcedb92bbce]0x00007fcedb92bbce is at code_begin+1806 in an Interpreter codelet

```

Since the stacks differ, NMT does not merge the sections. And that is fine; it shouldn't do that. The test should cope somehow.


Comments
Fix request JDK 21u: Fixes intermittent errors in NMT tests by disabling compilation in that test (-Xint). No risk, test-change only.
10-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u/pull/349 Date: 2023-11-10 11:37:52 +0000
10-11-2023

Changeset: 6b21ff61 Author: Thomas Stuefe <stuefe@openjdk.org> Date: 2023-11-10 10:44:11 +0000 URL: https://git.openjdk.org/jdk/commit/6b21ff61dad6f633c744c1c33c29ea86183b509d
10-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16583 Date: 2023-11-09 16:05:14 +0000
09-11-2023