Categories: OpenJDK

ShowRegistersOnAssertTest Failure on Windows AArch64

I recently investigated why the ShowRegistersOnAssertTest.java test was failing on Windows AArch64. This test was originally added in [JDK-8191101] Show register content in hs-err file on assert – Java Bug System to “retrieve the current context when an assert happens and make that part of the hs-err file.” I searched the codebase for the strings Registers:" and "RAX=" (used in the test) and verified that the hserr output the test is examining is generated by the os::print_context method (see the x86_64 Windows os::print_context, Linux os::print_context, and BSD os::print_context implementations).

The aarch64 Windows os::print_context, Linux os::print_context, and BSD os::print_context implementations use different register names. BSD’s os::print_context writes x0= to the error log whereas aarch64 Windows os::print_context writes X0 =. The BSD implementation should fail this test as well but the log in Update the copyright year · swesonga/jdk@3470f00 did not show this test running! It also didn’t appear in jdk/test/hotspot/jtreg/ProblemList.txt. Actually, a search for the string ShowRegistersOnAssertTest yielded results in that test file only. That led me to review it more closely and find that it didn’t run on macos because the test requires Linux or Windows. However, the fix for the test failure on Windows was obviously using the correct pattern for Windows:

diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java
index 3b038ebd8a0..b0138625450 100644
--- a/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java
+++ b/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java
@@ -76,7 +76,11 @@ private static void do_test(boolean do_assert, // true - assert, false - guarant
             } else if (Platform.isX86()) {
                 pattern = new Pattern[] { Pattern.compile("Registers:"), Pattern.compile("EAX=.*")};
             } else if (Platform.isAArch64()) {
-                pattern = new Pattern[] { Pattern.compile("Registers:"), Pattern.compile("R0=.*")};
+                if (Platform.isLinux()) {
+                    pattern = new Pattern[] { Pattern.compile("Registers:"), Pattern.compile("R0=.*")};
+                } else if (Platform.isWindows()) {
+                    pattern = new Pattern[] { Pattern.compile("Registers:"), Pattern.compile("X0 =.*")};
+                }
             } else if (Platform.isS390x()) {
                 pattern = new Pattern[] { Pattern.compile("General Purpose Registers:"),
                                           Pattern.compile("^-{26}$"),

To verify that the data in the error log matched what the test expected, I used this change:

diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java
index 3b038ebd8a0..76917f06a02 100644
--- a/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java
+++ b/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java
@@ -87,7 +87,9 @@ private static void do_test(boolean do_assert, // true - assert, false - guarant
                 pattern = new Pattern[] { Pattern.compile("Registers:") };
             }
             // Pattern match the hs_err_pid file.
-            HsErrFileUtils.checkHsErrFileContent(hs_err_file, pattern, false);
+            boolean is_verbose = false;
+            boolean printHserrOnError = true;
+            HsErrFileUtils.checkHsErrFileContent(hs_err_file, pattern, null, true, is_verbose, printHserrOnError);
         }
     }

I filed [JDK-8366483] ShowRegistersOnAssertTest uses wrong register pattern string for Windows on AArch64 – Java Bug System and fixed the test bug in 8366483: ShowRegistersOnAssertTest uses wrong register pattern string for Windows on AArch64 by swesonga · Pull Request #27022 · openjdk/jdk.

Article info



Leave a Reply

Your email address will not be published. Required fields are marked *