Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8304916

ShowMessageBoxOnError broken

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • tbd
    • 21
    • hotspot

      ShowMessageBoxOnError (aka SMBOE) is very useful.

      (JDK-8296498 would also be useful, and if implemented should use common logic with SMBOE. So this bug applies to that RFE as well.)

      SMBOE needs periodic maintenance to ensure that it works correctly on our various platforms. It is currently broken on BSD (MacOS).

      Below is a session that shows some severe problems with SMBOE:

      A. The debugger command the Hotspot suggests and runs for you is completly wrong.

      B. The thread id reported by Hotspot is not meaningful to the debugger.

      C. The logic Hotspot uses to create the debugger suggestion is not derived from the configuration that Hotspot was compiled with.

      D. The suggested invocation of the debugger is helpful (when it works) but it is a bit cryptic. There should be a link to further documentation in the message that SMBOE prints.

      These bugs can and should be fixed on BSD, and perhaps other platforms.

      Note that it makes no sense to build Hotspot on llvm and then offer gdb as a debugging solution. The SMBOE message logic should be correct with respect to THE SPECIFIC TOOLCHAIN that Hotspot was compiled under. This may require some makefile configuration logic, which would be all to the good.

      Similar bugs may exist on Windows or Linux; that should be investigated. We should have some sort of regression test for this on each platform, so we find out, more systematically, when the logic bits are rotten.

      Perhaps, in addition, the helpful text printed by Hotspot for SMBOE should include some narrative prose that explains what is going on, and what resources a programmer might access to find a debugger and apply it to the situation. A platform-independent HTTP or file reference, to a platform-independent documentation, would be much better than nothing. After all, Hotspot might not guess right how to invoke the debugger; all it can do is suggest the right one with the right arguments (we hope).


      ```
      <<MAIN SHELL WINDOW>>

      $ uname -v
      Darwin Kernel Version 20.6.0: Tue Jun 21 20:50:27 PDT 2022; root:xnu-7195.141.32~1/RELEASE_ARM64_T8101

      $ INJECT='const char *s=p, *t=p; while (s) {s+=(long)s;t+=*s;} if (!t) return true;'
      $ sed -I .bak 's/.*const char[*] p.*{$/&/'"$INJECT"/ test/hotspot/gtest/utilities/test_utf8.cpp
      $ git diff test/hotspot/gtest/utilities/test_utf8.cpp
      diff --git a/test/hotspot/gtest/utilities/test_utf8.cpp b/test/hotspot/gtest/utilities/test_utf8.cpp
      index ffd8121075b..a422febfb66 100644
      --- a/test/hotspot/gtest/utilities/test_utf8.cpp
      +++ b/test/hotspot/gtest/utilities/test_utf8.cpp
      @@ -31,7 +31,7 @@ static void stamp(char* p, size_t len) {
         }
       }
       
      -static bool test_stamp(const char* p, size_t len) {
      +static bool test_stamp(const char* p, size_t len) {const char *s=p, *t=p; while (s) {s+=(long)s;t+=*s;} if (!t) return true;
         for (const char* q = p; q < p + len; q++) {
           if (*q != 'A') {
             return false;

      $ _JAVA_OPTIONS='-XX:+ShowMessageBoxOnError' make exploded-test TEST=gtest:utf8
      Building target 'exploded-test' in configuration 'macosx-aarch64-server-fastdebug'
      Updating hotspot/variant-server/libjvm/gtest/libjvm.dylib due to 1 file(s)
      Test selection 'gtest:utf8', will run:
      * gtest:utf8/server

      Running test 'gtest:utf8/server'
      Note: Google Test filter = utf8*
      [==========] Running 2 tests from 1 test suite.
      [----------] Global test environment set-up.
      [----------] 2 tests from utf8
      [ RUN ] utf8.jchar_length_vm
      Picked up _JAVA_OPTIONS: -XX:+ShowMessageBoxOnError
      ==============================================================================
      Unexpected Error
      ------------------------------------------------------------------------------
      SIGSEGV (0xb) at pc=0x00000001055fcaf0, pid=74163, tid=259

      Do you want to debug the problem?

      To debug, run 'gdb /proc/74163/exe 74163'; then switch to thread 259 (0x0000000000000103)
      Enter 'yes' to launch gdb automatically (PATH must include gdb)
      Otherwise, press RETURN to abort...
      ==============================================================================
      yes
      warning: Overwriting existing definition for 'r'.
      (lldb) target create "/pr"
      error: unable to find executable for '/pr'

      ```

      ```
      <<OTHER SHELL WINDOW>>

      $ ls -l /proc/74163/exe
      ls: /proc/74163/exe: No such file or directory

      <<NO

      $ gdb /proc/74163/exe 74163
      warning: Overwriting existing definition for 'r'.
      (lldb) target create "/proc/74163/exe"
      error: unable to find executable for '/proc/74163/exe'
      (lldb) quit

      <<BUG PART A -- GDB IS THE WRONG COMMAND>>

      $ lldb -p 74163
      warning: Overwriting existing definition for 'r'.
      (lldb) process attach --pid 74163
      Process 74163 stopped
      * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
          frame #0: 0x0000000198953d9c libsystem_kernel.dylib`__wait4 + 8
      libsystem_kernel.dylib`__wait4:
      -> 0x198953d9c <+8>: b.lo 0x198953dbc ; <+40>
          0x198953da0 <+12>: pacibsp
          0x198953da4 <+16>: stp x29, x30, [sp, #-0x10]!
          0x198953da8 <+20>: mov x29, sp
      Target 0: (gtestLauncher) stopped.

      Executable module set to "/Users/jrose/Projects/openjdk/jdk/worktrees/trace-init/build/macosx-aarch64-server-fastdebug/images/test/hotspot/gtest/server/gtestLauncher".
      Architecture set to: arm64e-apple-macosx-.
      (lldb) thread info
      thread info
      thread #1: tid = 0xd705b5, 0x0000000198953d9c libsystem_kernel.dylib`__wait4 + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP

      (lldb) thread info 259
      thread info 259
      error: no thread with index: "259"

      <<BUG PART B -- PROVIDED THREAD NUMBER IS USELESS>>

      ```

            Unassigned Unassigned
            jrose John Rose
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: