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

thread id on Linux is inconsistent in error and log outputs

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 9
    • 9
    • hotspot
    • b78
    • x86
    • linux_2.6

        Currently on Linux we call system method pthread_self() to get current thread id:

          intx os::current_thread_id() { return (intx)pthread_self(); }

        But pthread_self() returns pthread_t type which is defined
        as unsigned long on Linux. As result we may truncate that value when
        it is cast to (intx) in 32-bits VM.

        But for some output (for example, Thread::print_on_error()) we use different
        value thread->osthread()->thread_id(). Which is LWP id on Linux.
        It's type is pid_t which is unsigned int.

        Also defaultStream::hold() use INTX_FORMAT to print this id and
        as result we can get negative values.

        [kvn@intelsdv03 jvmg]$ fastdebug/bin/java -XX:AbortVMOnException=java.lang.NoClassDefFoundError -Xcomp -XX:+BackgroundCompilation -XX:CICompilerCount=8 -XX:+PrintCompilation t
        VM option 'AbortVMOnException=java.lang.NoClassDefFoundError'
        VM option '+BackgroundCompilation'
        VM option 'CICompilerCount=8'
        VM option '+PrintCompilation'
          1 java.lang.Thread::<init> (49 bytes)
          2 java.lang.System::getProperty (25 bytes)
          8 s! java.lang.ClassLoader::loadClass (58 bytes)
          7 java.lang.System::getSecurityManager (4 bytes)
          6 java.lang.String::lastIndexOf (12 bytes)
          5 s sun.misc.Launcher$AppClassLoader::loadClass (40 bytes)
          4 java.lang.ClassLoader::loadClass (7 bytes)
          3 s java.lang.ClassLoader::loadClassInternal (6 bytes)
        --- n java.lang.ClassLoader::findLoadedClass0
        --- n java.lang.ClassLoader::findBootstrapClass
        --- n java.security.AccessController::doPrivileged (static)
        --- n java.security.AccessController::doPrivileged (static)
        --- n java.lang.Class::getPrimitiveClass (static)
        # To suppress the following error report, specify this argument
        # after -XX: or in .hotspotrc: SuppressErrorAt=/exceptions.cpp:378
        #
        # An unexpected error has been detected by Java Runtime Environment:
        #
        # Internal Error (/BUILD_AREA/jdk7/hotspot/src/share/vm/utilities/exceptions.cpp:378), pid=19034, tid=4160498576
        # Error: Saw java.lang.NoClassDefFoundError, aborting
        #
        # Java VM: Java HotSpot(TM) Server VM (12.0-b01-fastdebug compiled mode linux-x86)
        # An error report file with more information is saved as:
        # /export/kvn/build/linux_amd64_compiler2/jvmg/hs_err_pid19034.log
        #
        # If you would like to submit a bug report, please visit:
        # http://java.sun.com/webapps/bugreport/crash.jsp
        #
        Current thread is 4160498576
        Dumping core ...
        Abort

        [kvn@intelsdv03 jvmg]$ grep write hotspot.log
        <writer thread='-1346954352'/>
        <writer thread='-1346425968'/>
        <writer thread='-1345369200'/>
        <writer thread='-1344840816'/>
        <writer thread='-1344312432'/>
        <writer thread='-1343784048'/>
        <writer thread='-1343255664'/>
        <writer thread='-1345897584'/>
        <writer thread='-134468720'/>

        [kvn@intelsdv03 jvmg]$ cat hs_err_pid19034.log
        #
        # An unexpected error has been detected by Java Runtime Environment:
        #
        # Internal Error (/BUILD_AREA/jdk7/hotspot/src/share/vm/utilities/exceptions.cpp:378), pid=19034, tid=4160498576
        # Error: Saw java.lang.NoClassDefFoundError, aborting
        #
        # Java VM: Java HotSpot(TM) Server VM (12.0-b01-fastdebug compiled mode linux-x86)
        # If you would like to submit a bug report, please visit:
        # http://java.sun.com/webapps/bugreport/crash.jsp
        #

        --------------- T H R E A D ---------------

        Current thread (0x08063c00): JavaThread "main" [_thread_in_vm, id=19035, stack(0xf7f72000,0xf7fc3000)]

        Stack: [0xf7f72000,0xf7fc3000], sp=0xf7fc1f00, free space=319k
        Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
        V [libjvm.so+0xb06c83]
        V [libjvm.so+0x5becb5]
        V [libjvm.so+0x61f6f9]
        V [libjvm.so+0x61fdc2]
        V [libjvm.so+0xa710e0]
        V [libjvm.so+0xa70f4d]
        V [libjvm.so+0x776f51]
        V [libjvm.so+0x6cfe61]
        C [libjli.so+0x4e17]
        C [libjli.so+0x32d3] JavaMain+0x1d3
        C [libpthread.so.0+0x52db]


        --------------- P R O C E S S ---------------

        Java Threads: ( => current thread )
          0x0821dc00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=19064, stack(0xafaa0000,0xafaf1000)]
          0x0821b400 JavaThread "CompilerThread7" daemon [_thread_in_native, id=19063, stack(0xafaf1000,0xafb72000)]
          0x08219400 JavaThread "CompilerThread6" daemon [_thread_in_native, id=19062, stack(0xafb72000,0xafbf3000)]
          0x08217400 JavaThread "CompilerThread5" daemon [_thread_blocked, id=19061, stack(0xafbf3000,0xafc74000)]
          0x08215000 JavaThread "CompilerThread4" daemon [_thread_in_native, id=19060, stack(0xafc74000,0xafcf5000)]
          0x08213000 JavaThread "CompilerThread3" daemon [_thread_in_native, id=19059, stack(0xafcf5000,0xafd76000)]
          0x08211000 JavaThread "CompilerThread2" daemon [_thread_in_native, id=19058, stack(0xafd76000,0xafdf7000)]
          0x0820f800 JavaThread "CompilerThread1" daemon [_thread_in_native, id=19057, stack(0xafdf7000,0xafe78000)]
          0x0820c000 JavaThread "CompilerThread0" daemon [_thread_blocked, id=19056, stack(0xafe78000,0xafef9000)]
          0x0820a400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=19055, stack(0xafef9000,0xaff4a000)]
          0x081ee000 JavaThread "Finalizer" daemon [_thread_blocked, id=19054, stack(0xaff4a000,0xaff9b000)]
          0x081ec400 JavaThread "Reference Handler" daemon [_thread_blocked, id=19053, stack(0xaff9b000,0xaffec000)]
        =>0x08063c00 JavaThread "main" [_thread_in_vm, id=19035, stack(0xf7f72000,0xf7fc3000)]

        Other Threads:
          0x081e7400 VMThread [stack: 0xaffec000,0xb006d000] [id=19052]
          0xaf900800 WatcherThread [stack: 0xafa1f000,0xafaa0000] [id=19065]

              jmanson Jeremy Manson (Inactive)
              kvn Vladimir Kozlov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: