JDK-8302320 : AsyncGetCallTrace obtains too few frames in sanity test
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: 18
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: x86
  • Submitted: 2023-02-13
  • Updated: 2024-12-05
  • Resolved: 2023-02-21
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 17 JDK 21
17.0.8Fixed 21 b11Fixed
Related Reports
Relates :  
Relates :  
Description
AsyncGetCallTrace returns only 3 frames in the sanity test, while GetStackTrace returns 11. The GetStackTrace trace conforms to the actual source code.

GetStackTrace returns a stack trace like the following:

```
Frame 0: Native frame Lprofiling/sanity/ASGSTBaseTest;.checkAsyncGetStackTraceCall()Z
Frame 1: Java frame   Lprofiling/sanity/ASGSTBaseTest;.main([Ljava/lang/String;)V: 0
Frame 2: Java frame   Ljava/lang/invoke/LambdaForm$DMH.0x0000000801002000;.invokeStatic(Ljava/lang/Object;Ljava/lang/Object;)V: 10
Frame 3: Java frame   Ljava/lang/invoke/LambdaForm$MH.0x0000000801003400;.invoke(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;: 33
Frame 4: Java frame   Ljava/lang/invoke/Invokers$Holder;.invokeExact_MT(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;: 20
Frame 5: Java frame   Ljdk/internal/reflect/DirectMethodHandleAccessor;.invokeImpl(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;: 55
Frame 6: Java frame   Ljdk/internal/reflect/DirectMethodHandleAccessor;.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;: 23
Frame 7: Java frame   Ljava/lang/reflect/Method;.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;: 102
Frame 8: Java frame   Lcom/sun/javatest/regtest/agent/MainWrapper$MainThread;.run()V: 134
Frame 9: Java frame   Ljava/lang/Thread;.runWith(Ljava/lang/Object;Ljava/lang/Runnable;)V: 5
Frame 10: Java frame   Ljava/lang/Thread;.run()V: 19
```

AsyncGetCallTrace returns:

```
Frame 0: Native frame Lprofiling/sanity/ASGSTBaseTest;.checkAsyncGetStackTraceCall()Z
Frame 1: Java frame   Lprofiling/sanity/ASGSTBaseTest;.main([Ljava/lang/String;)V: 0
Frame 2: Java frame   Ljava/lang/invoke/LambdaForm$DMH.0x0000000801002000;.invokeStatic(Ljava/lang/Object;Ljava/lang/Object;)V: 10
```

This is related to a bug in `frame::is_safe_for_sender` which is already fixed on PPC (https://bugs.openjdk.org/browse/JDK-8209996) but is still present on x86, albeit only for AsyncGetCallTrace and not for JFR.

The issue itself first appeared with the implementation of JDK-8271820 which altered the implementation of Java reflection which is used by the JTREG test runner. So it might affect other code that uses reflection heavily.

This test error occurs when checking for the length of the returned traces in the sanity test (see https://github.com/parttimenerd/jdk/commit/98fe63f42f5a3d5ec9fd151b034dfeb3ef767afd). 
Comments
Fix Request (17u): Fixes a bug in ASGCT and JFR related to interpreted frames. Tested using SAPs nightly tests. Applies clean.
07-03-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/1197 Date: 2023-03-06 08:12:47 +0000
06-03-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u/pull/366 Date: 2023-03-06 07:58:36 +0000
06-03-2023

This fix is integrated in jdk-21+11-869.
24-02-2023

Changeset: db483a38 Author: Johannes Bechberger <johannes.bechberger@sap.com> Committer: Jorn Vernee <jvernee@openjdk.org> Date: 2023-02-21 14:33:02 +0000 URL: https://git.openjdk.org/jdk/commit/db483a38a815f85bd9668749674b5f0f6e4b27b4
21-02-2023

The error is also reproducible with a self-contained test case and JFR (https://gist.github.com/parttimenerd/502251b67d3e42baad17419442a72c39): ```java import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Class<?> klass = Main.class; Method mainMethod = klass.getMethod("main"); mainMethod.invoke(null); } public static void main() { javaLoop(); } public static void javaLoop() { long start = System.currentTimeMillis(); while (start + 3000 > System.currentTimeMillis()); } } ```
16-02-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/12535 Date: 2023-02-13 14:39:00 +0000
13-02-2023