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

sun.misc.Signal#handle for SIGBUS can deadlock JVM

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      os_x

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_112"
      Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
      Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      macOS Sierra 10.12.2

      A DESCRIPTION OF THE PROBLEM :
      An application can register for process level signals via sun.misc.Signal. Registering for SIGBUS is allowed, presumably to detect if memory mapped files (or similar operations?). However SIGBUS may be thrown by macOS during "normal" JVM execution. If a SIGBUS is thrown the JVM attempts to dispatch the signal to the user's signal handler instead of the JVM signal handler. This "Java: Signal Dispatcher" thread may dead lock waiting for a safe point and the SIGBUS condition continuously triggers because the JVM signal handler was not notified and the condition is not corrected by the JVM.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      A reproducer for this issue can be found at https://github.com/Scottmitch/jdksigbus. See the README in that repository for instructions on how to run the reproducer.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The JVM should correct the condition which caused the SIGBUS and continue executing.
      ACTUAL -
      The JVM enters a live lock condition.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      (lldb) bt
      * thread #10: tid = 0x3acc3, 0x00007fff8e7cc136 libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'Java: Signal Dispatcher'
        * frame #0: 0x00007fff8e7cc136 libsystem_kernel.dylib`__psynch_cvwait + 10
          frame #1: 0x00007fff938d1560 libsystem_pthread.dylib`_pthread_cond_wait + 693
          frame #2: 0x0000000101bc77a1 libjvm.dylib`os::PlatformEvent::park(this=0x00000001001a3800) + 529 at os_bsd.cpp:4382
          frame #3: 0x0000000101b681d4 libjvm.dylib`::ParkCommon(ev=0x00000001001a3800, timo=0) + 100 at mutex.cpp:424
          frame #4: 0x0000000101b695f0 libjvm.dylib`Monitor::ILock(this=0x0000000100304610, Self=0x0000000100864000) + 552 at mutex.cpp:491
          frame #5: 0x0000000101b6977c libjvm.dylib`Monitor::lock_without_safepoint_check(this=0x0000000100304610, Self=0x0000000100864000) + 114 at mutex.cpp:959
          frame #6: 0x0000000101b69802 libjvm.dylib`Monitor::lock_without_safepoint_check(this=0x0000000100304610) + 32 at mutex.cpp:965
          frame #7: 0x0000000101cc496e libjvm.dylib`SafepointSynchronize::block(thread=0x0000000100864000) + 950 at safepoint.cpp:703
          frame #8: 0x0000000101264842 libjvm.dylib`ThreadStateTransition::transition_and_fence(thread=0x0000000100864000, from=_thread_blocked, to=_thread_in_vm) + 274 at interfaceSupport.hpp:184
          frame #9: 0x000000010150ba7e libjvm.dylib`ThreadStateTransition::trans_and_fence(this=0x000000011832d728, from=_thread_blocked, to=_thread_in_vm) + 42 at interfaceSupport.hpp:232
          frame #10: 0x000000010126491e libjvm.dylib`ThreadBlockInVM::~ThreadBlockInVM(this=0x000000011832d728) + 66 at interfaceSupport.hpp:314
          frame #11: 0x0000000101bccd1f libjvm.dylib`::check_pending_signals(wait=true) + 351 at os_bsd.cpp:2069
          frame #12: 0x0000000101bccd48 libjvm.dylib`os::signal_wait() + 20 at os_bsd.cpp:2110
          frame #13: 0x0000000101bc367c libjvm.dylib`::signal_thread_entry(thread=0x0000000100864000, __the_thread__=0x0000000100864000) + 60 at os.cpp:249
          frame #14: 0x0000000101db5f06 libjvm.dylib`JavaThread::thread_main_inner(this=0x0000000100864000) + 426 at thread.cpp:1699
          frame #15: 0x0000000101db97e2 libjvm.dylib`JavaThread::run(this=0x0000000100864000) + 674 at thread.cpp:1679
          frame #16: 0x0000000101bd0d8b libjvm.dylib`::java_start(thread=0x0000000100864000) + 571 at os_bsd.cpp:752
          frame #17: 0x00007fff938d105a libsystem_pthread.dylib`_pthread_body + 131
          frame #18: 0x00007fff938d0fd7 libsystem_pthread.dylib`_pthread_start + 176
          frame #19: 0x00007fff938ce3ed libsystem_pthread.dylib`thread_start + 13

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      A reproducer for this issue can be found at https://github.com/Scottmitch/jdksigbus. See the README in that repository for instructions on how to run the reproducer.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The application shouldn't register for SIGBUS.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                shshahma Shafi Ahmad (Inactive)
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: