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

semaphores of AsyncLogWriter may be broken when JVM is exiting.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 17
    • Fix Version/s: 18
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b03
    • CPU:
      generic
    • OS:
      os_x

      Backports

        Description

        currently, async log thread (the log flusher) doesn't quit at all.
        It assumes that OS reclaims all resources like thread, semaphore.

        when JVM is exiting, it's possible to observe
        OSXSemaphore::wait() and OSXSemaphore::signal() fail with return value 15.
        #define KERN_INVALID_NAME 15
        /* The name doesn't denote a right in the task.

        the crash sight looks like this:
        Target 0: (java) stopped.
        (lldb) bt
        * thread #9, name = 'Java: AsyncLog Thread', stop reason = breakpoint 2.2
          * frame #0: 0x0000000102dcdf4f libjvm.dylib`report_vm_error(file="/Users/xxinliu/Devel/jdk/src/hotspot/os/bsd/semaphore_bsd.cpp", line=66, error_msg="assert(ret == 0) failed", detail_fmt="Failed to wait on semaphore") at debug.cpp:270:17
            frame #1: 0x000000010372e5b1 libjvm.dylib`OSXSemaphore::wait(this=0x0000000103e22800) at semaphore_bsd.cpp:66:3
            frame #2: 0x0000000102da1f3e libjvm.dylib`Semaphore::wait(this=0x0000000103e227f8) at semaphore.hpp:55:39
            frame #3: 0x000000010342346f libjvm.dylib`AsyncLogLocker::AsyncLogLocker(this=0x000070000d627eb0) at logAsyncWriter.cpp:39:11
            frame #4: 0x0000000103422395 libjvm.dylib`AsyncLogLocker::AsyncLogLocker(this=0x000070000d627eb0) at logAsyncWriter.cpp:38:20
            frame #5: 0x0000000103422aed libjvm.dylib`AsyncLogWriter::write(this=0x0000000100214dc0) at logAsyncWriter.cpp:128:20
            frame #6: 0x0000000103422eb9 libjvm.dylib`AsyncLogWriter::run(this=0x0000000100214dc0) at logAsyncWriter.cpp:159:5
            frame #7: 0x0000000103927bae libjvm.dylib`Thread::call_run(this=0x0000000100214dc0) at thread.cpp:394:9
            frame #8: 0x0000000103634af7 libjvm.dylib`thread_native_entry(thread=0x0000000100214dc0) at os_bsd.cpp:591:11
            frame #9: 0x00007fff6c27a109 libsystem_pthread.dylib`_pthread_start + 148
            frame #10: 0x00007fff6c275b8b libsystem_pthread.dylib`thread_start + 15


        It's Main thread is exiting. all static variables are destroying. therefore, OSXSemaphore may have been destroyed.

        * thread #2
          * frame #0: 0x00007fff31e03889 CoreDisplay`std::__1::unique_ptr<CoreDisplay::IOBacklightWrapper, std::__1::default_delete<CoreDisplay::IOBacklightWrapper> >::reset(CoreDisplay::IOBacklightWrapper*) + 9
            frame #1: 0x00007fff6c11f13c libsystem_c.dylib`__cxa_finalize_ranges + 319
            frame #2: 0x00007fff6c11f412 libsystem_c.dylib`exit + 55
            frame #3: 0x000000010011c871 libjli.dylib`apple_main(arg=0x00007ffeefbfe880) at java_md_macosx.m:309:5
            frame #4: 0x00007fff6c27a109 libsystem_pthread.dylib`_pthread_start + 148
            frame #5: 0x00007fff6c275b8b libsystem_pthread.dylib`thread_start + 15

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                xliu Xin Liu
                Reporter:
                xliu Xin Liu
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: