jdk icon indicating copy to clipboard operation
jdk copied to clipboard

8292362: java/lang/Thread/jni/AttachCurrentThread/AttachTest.java#id1 failed on some platforms

Open theaoqi opened this issue 2 years ago • 11 comments

For example, java/lang/Thread/jni/AttachCurrentThread/AttachTest.java#id1 failed on LoongArch64 (probably other platforms unsupported in src/java.base/share/classes/jdk/internal/foreign/CABI.java might have the same issue):

Exception in thread "main" java.lang.UnsupportedOperationException: Unsupported os, arch, or address size: Linux, loongarch64, 64
at java.base/jdk.internal.foreign.CABI.current(CABI.java:69)
at java.base/jdk.internal.foreign.abi.SharedUtils.getSystemLinker(SharedUtils.java:237)
at java.base/java.lang.foreign.Linker.nativeLinker(Linker.java:198)
at ImplicitAttach.main(ImplicitAttach.java:48)

Progress

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

Issue

  • JDK-8292362: java/lang/Thread/jni/AttachCurrentThread/AttachTest.java#id1 failed on some platforms

Contributors

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9877

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

Using diff file

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

theaoqi avatar Aug 15 '22 12:08 theaoqi

:wave: Welcome back aoqi! 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.

bridgekeeper[bot] avatar Aug 15 '22 12:08 bridgekeeper[bot]

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

  • core-libs

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[bot] avatar Aug 15 '22 12:08 openjdk[bot]

Webrevs

mlbridge[bot] avatar Aug 15 '22 12:08 mlbridge[bot]

Linker.nativeLinker is currently specified to throw UOE so you might find the following will avoid ports needing to change the test less often:

--- a/test/jdk/java/lang/Thread/jni/AttachCurrentThread/ImplicitAttach.java
+++ b/test/jdk/java/lang/Thread/jni/AttachCurrentThread/ImplicitAttach.java
@@ -45,7 +45,13 @@ public class ImplicitAttach {
         }
         latch = new CountDownLatch(threadCount);
 
-        Linker abi = Linker.nativeLinker();
+        Linker abi;
+        try {
+            abi = Linker.nativeLinker();
+        } catch (UnsupportedOperationException e) {
+            System.out.println("Test skipped, no native linker on this platform");
+            return;
+        }
 
         // stub to invoke callback
         MethodHandle callback = MethodHandles.lookup()

AlanBateman avatar Aug 15 '22 12:08 AlanBateman

Linker.nativeLinker is currently specified to throw UOE so you might find the following will avoid ports needing to change the test less often:

--- a/test/jdk/java/lang/Thread/jni/AttachCurrentThread/ImplicitAttach.java
+++ b/test/jdk/java/lang/Thread/jni/AttachCurrentThread/ImplicitAttach.java
@@ -45,7 +45,13 @@ public class ImplicitAttach {
         }
         latch = new CountDownLatch(threadCount);
 
-        Linker abi = Linker.nativeLinker();
+        Linker abi;
+        try {
+            abi = Linker.nativeLinker();
+        } catch (UnsupportedOperationException e) {
+            System.out.println("Test skipped, no native linker on this platform");
+            return;
+        }
 
         // stub to invoke callback
         MethodHandle callback = MethodHandles.lookup()

This worked. Thanks, @AlanBateman ! java/lang/Thread/jni/AttachCurrentThread/AttachTest.java#id1 passed:

Output and diagnostic info for process 9917 was saved into 'pid-9917-output.log'
Test skipped, no native linker on this platform


[2022-08-15T13:17:02.430832622Z] Waiting for completion for process 9917
[2022-08-15T13:17:02.430922220Z] Waiting for completion finished for process 9917
STDERR:

JavaTest Message: Test complete.


TEST RESULT: Passed. Execution successful

theaoqi avatar Aug 15 '22 13:08 theaoqi

Shouldn't we throw a SkippedException in this case?

dholmes-ora avatar Aug 15 '22 13:08 dholmes-ora

/contributor add alanb

theaoqi avatar Aug 15 '22 13:08 theaoqi

@theaoqi Contributor Alan Bateman <[email protected]> successfully added.

openjdk[bot] avatar Aug 15 '22 13:08 openjdk[bot]

Shouldn't we throw a SkippedException in this case?

It's the child VM that skips so throwing SkippedException would require special handling in the parent.

AlanBateman avatar Aug 15 '22 13:08 AlanBateman

Shouldn't we throw a SkippedException in this case?

It's the child VM that skips so throwing SkippedException would require special handling in the parent.

Like this?

diff --git a/test/jdk/java/lang/Thread/jni/AttachCurrentThread/AttachTest.java b/test/jdk/java/lang/Thread/jni/AttachCurrentThread/AttachTest.java
index b93e7918014..156bbe35c62 100644
--- a/test/jdk/java/lang/Thread/jni/AttachCurrentThread/AttachTest.java
+++ b/test/jdk/java/lang/Thread/jni/AttachCurrentThread/AttachTest.java
@@ -48,6 +48,8 @@ import java.util.stream.Stream;
 import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.process.OutputAnalyzer;
 
+import jtreg.SkippedException;
+
 public class AttachTest {
     static final String TEST_CLASSES = System.getProperty("test.classes");
     static final String JAVA_LIBRARY_PATH = System.getProperty("java.library.path");
@@ -63,6 +65,9 @@ public class AttachTest {
                 .executeTestJava(opts)
                 .outputTo(System.out)
                 .errorTo(System.out);
+        if (outputAnalyzer.getOutput().contains("Test skipped, no native linker on this platform")) {
+            throw new SkippedException("Test skipped, no native linker on this platform");
+        }
         outputAnalyzer.shouldHaveExitValue(0);
     }
 }

Do I need to add this change?

theaoqi avatar Aug 15 '22 13:08 theaoqi

Shouldn't we throw a SkippedException in this case?

It's the child VM that skips so throwing SkippedException would require special handling in the parent.

Like this?

diff --git a/test/jdk/java/lang/Thread/jni/AttachCurrentThread/AttachTest.java b/test/jdk/java/lang/Thread/jni/AttachCurrentThread/AttachTest.java
index b93e7918014..156bbe35c62 100644
--- a/test/jdk/java/lang/Thread/jni/AttachCurrentThread/AttachTest.java
+++ b/test/jdk/java/lang/Thread/jni/AttachCurrentThread/AttachTest.java
@@ -48,6 +48,8 @@ import java.util.stream.Stream;
 import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.process.OutputAnalyzer;
 
+import jtreg.SkippedException;
+
 public class AttachTest {
     static final String TEST_CLASSES = System.getProperty("test.classes");
     static final String JAVA_LIBRARY_PATH = System.getProperty("java.library.path");
@@ -63,6 +65,9 @@ public class AttachTest {
                 .executeTestJava(opts)
                 .outputTo(System.out)
                 .errorTo(System.out);
+        if (outputAnalyzer.getOutput().contains("Test skipped, no native linker on this platform")) {
+            throw new SkippedException("Test skipped, no native linker on this platform");
+        }
         outputAnalyzer.shouldHaveExitValue(0);
     }
 }

Do I need to add this change?

That would work too but I think what you have in the PR now is okay.

AlanBateman avatar Aug 15 '22 14:08 AlanBateman

@theaoqi 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:

8292362: java/lang/Thread/jni/AttachCurrentThread/AttachTest.java#id1 failed on some platforms

Co-authored-by: Alan Bateman <[email protected]>
Reviewed-by: alanb

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 11 new commits pushed to the master branch:

  • d1edda8ff52e172a85d102d7d5062b9cc401beea: 8292338: aarch64: Use cbnz instruction in gen_continuation_enter when possible
  • 21f4eb2233a95be44a5db59b7791cd952ddbd56e: 6521141: DebugGraphics NPE @ setFont();
  • 6e6ae596d6bd73909b90911e01fbd0c16f6335e1: 8292286: Convert PlaceholderTable to ResourceHashtable
  • ea2c82e74f5580f396920f9e561cbec80c03f373: 8291949: Unexpected extending of SupportedGroups
  • b5707b0376660cd8763e46d525ba614b08a59d7b: 8292196: Reduce runtime of java.util.regex microbenchmarks
  • b00eedeb029445417f99e8aa4e8fca12e5c69155: 8291511: Redefinition of EXIT_FAILURE in libw2k_lsa_auth
  • 3a090777bada2e00f573fe8ab113bfa3884982eb: 8291337: Reduce runtime of vm.lamdba microbenchmarks
  • dd2034b00725f0fc777c1706b1db898475e89c5c: 8291972: Fix double copy of arguments when thawing two interpreted frames
  • aa5b71893307b9fe6137bc3541edccaab73735ac: 8292182: [TESTLIB] Enhance JAXPPolicyManager to setup required permissions for jtreg version 7 jar
  • 695bb3939135394a4627d1c41cfc30d11b19bf48: 8292347: Remove unused Type::is_ptr_to_boxing_obj
  • ... and 1 more: https://git.openjdk.org/jdk/compare/fd4b2f2868ac6eaf192b50db5c5adc76e0d54308...master

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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@AlanBateman) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

openjdk[bot] avatar Aug 16 '22 06:08 openjdk[bot]

Thanks to @AlanBateman for the review. /integrate

theaoqi avatar Aug 16 '22 07:08 theaoqi

@theaoqi Your change (at version b54d3fd06e21a862e822dfb06f52c0330f117ab4) is now ready to be sponsored by a Committer.

openjdk[bot] avatar Aug 16 '22 07:08 openjdk[bot]

/sponsor

AlanBateman avatar Aug 17 '22 08:08 AlanBateman

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

  • 0bfb12162f6035559a114176115b91aff6df3b64: 8292051: jdk/internal/misc/TerminatingThreadLocal/TestTerminatingThreadLocal.java failed "AssertionError: Expected terminated values: [666] but got: []"
  • 1d9c2f7a6e3e897721ef99af8f383a07148b7c4e: 8292279: (fs) Use try-with-resources to release NativeBuffer
  • a25e1dc53cecc5dd917ac0f76fd86ef1f074adba: 8292285: C2: remove unreachable block after NeverBranch-to-Goto conversion
  • 1ef4e484889c77cccadea44025924b2d010ba2cc: 8273860: Javadoc Deprecated API list should not use italic font for description column
  • 0cc66aeae8cbf2d01be5f5ba38e46f1deb9ec7a6: 8285790: AArch64: Merge C2 NEON and SVE matching rules
  • da477b13661b39e1f48b674f7fd9ea1d26521fc3: 8292509: ProblemList java/lang/invoke/lambda/LogGeneratedClassesTest.java on windows
  • 01b87ba8e2c48ad29c1f4771973ebbe938967448: 8289616: Drop use of Thread.stop in AppContext
  • e44e3f0c1976a513c6637545f49f49de84cbac02: 8289106: Add model of class file versions to core reflection
  • c3d3662e52de434adb267485982fbf8541bdc0c8: 8292313: 2 runtime/cds/appcds tests fail after JDK-8284313
  • 3e122419b2979235f57c0dd549ca63647ea73753: 8290775: Some doc errors in DerOutputStream.java
  • ... and 13 more: https://git.openjdk.org/jdk/compare/fd4b2f2868ac6eaf192b50db5c5adc76e0d54308...master

Your commit was automatically rebased without conflicts.

openjdk[bot] avatar Aug 17 '22 08:08 openjdk[bot]

@AlanBateman @theaoqi Pushed as commit e61f6fc3940720f6ebc3ef360e25b880729cfa5a.

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

openjdk[bot] avatar Aug 17 '22 08:08 openjdk[bot]