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

(dc) assert "JNI handle should not be null" under Java_sun_nio_ch_FileDispatcher_preClose0()

    XMLWordPrintable

Details

    • b06
    • generic, x86
    • generic, linux, linux_2.6, linux_redhat_4.0
    • Not verified

    Backports

      Description

        This test case runs out of file handles and crashes the VM while
        running in finalization:

        import java.io.IOException;
        import java.net.InetSocketAddress;
        import java.nio.ByteBuffer;
        import java.nio.ByteOrder;
        import java.nio.channels.DatagramChannel;
        import java.nio.channels.SelectionKey;
        import java.nio.channels.Selector;

        public class FdBugTest {
                
            private static final String HOST = "localhost";
            private static final int PORT = 2525;
                
            static final DatagramChannel openChannel() throws IOException {
                DatagramChannel ret = DatagramChannel.open();
                ret.configureBlocking(false);
                ret.connect(new InetSocketAddress(HOST, PORT));
                return ret;
            }
                
            static final void send(DatagramChannel ch, ByteBuffer buf)
                throws IOException {
                buf.put(new byte[1024]);
                ch.write(buf);
            }
                
            static final void recv(DatagramChannel ch, ByteBuffer buf)
                throws IOException {
                Selector s = Selector.open();
                SelectionKey key = ch.register(s, SelectionKey.OP_READ);
                s.select(5000);
                if (s.selectedKeys().contains(key)) {
                    buf.clear();
                    ch.receive(buf);
                } else {
                    System.err.println("Timeout in receive");
                    return;
                }
                buf.flip();
            }
                
            public static void main(String[] args) {
                for (int i = 0; i < 1000; ++i) {
                    try {
                        ByteBuffer buf = ByteBuffer.allocate(65536);
                        buf.order(ByteOrder.BIG_ENDIAN);
                        DatagramChannel ch = openChannel();
                        send(ch, buf);
                        buf.clear();
                        recv(ch, buf);
                    } catch (IOException ex) {
                        System.err.println("err: " + ex);
                    }
                }
            }
        }


        Running with a fastdebug build on Solaris/SPARC prints the following error output.
        (Note: since there are no file handles left, the fatal exit handler cannot write
        out the hs_err_pid<nnn> file, so it prints to stderr instead):

        % java FdBugTest |& tee fastdebug_stderr.out

        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        Timeout in receive
        err: java.io.IOException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files
        # To suppress the following error report, specify this argument
        # after -XX: or in .hotspotrc: SuppressErrorAt=/jniHandles.hpp:169
        err: java.net.SocketException: Too many open files
        #
        # An unexpected error has been detected by Java Runtime Environment:
        #
        # Internal Error (/BUILD_AREA/jdk7.0/hotspot/src/share/vm/runtime/jniHandles.hpp, 169 [ Patched ]), pid=29656, tid=9
        #
        # Java VM: Java HotSpot(TM) Server VM (1.7.0-ea-fastdebug-b03-debug mixed mode)
        #
        # Error: assert(handle != 0,"JNI handle should not be null")
        # Can not save log file, dump to screen..
        #
        # An unexpected error has been detected by Java Runtime Environment:
        #
        # Internal Error (/BUILD_AREA/jdk7.0/hotspot/src/share/vm/runtime/jniHandles.hpp, 169 [ Patched ]), pid=29656, tid=9
        #
        # Java VM: Java HotSpot(TM) Server VM (1.7.0-ea-fastdebug-b03-debug mixed mode)
        #
        # Error: assert(handle != 0,"JNI handle should not be null")
        # 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 (0x00191000): JavaThread "Finalizer" daemon [_thread_in_vm, id=9]

        Stack: [0xd5f80000,0xd6000000), sp=0xd5ffe970, free space=506k
        Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
        V [libjvm.so+0x102f6e8]err: java.net.SocketException: Too many open files
        V [libjvm.so+0x436128]
        V [libjvm.so+0x6b95dc]

        C [libnio.so+0x3d74]
        C [libnio.so+0x3590] Java_sun_nio_ch_FileDispatcher_preClose0+0x2c
        j sun.nio.ch.FileDispatcher.preClose0(Ljava/io/FileDescriptor;)V+1
        j sun.nio.ch.FileDispatcher.preClose0(Ljava/io/FileDescriptor;)V+0
        j sun.nio.ch.DatagramDispatcher.preClose(Ljava/io/FileDescriptor;)V+1
        j sun.nio.ch.DatagramChannelImpl.implCloseSelectableChannel()V+14
        j java.nio.channels.spi.AbstractSelectableChannel.implCloseChannel()V+1
        j java.nio.channels.spi.AbstractInterruptibleChannel.close()V+23
        j sun.nio.ch.DatagramChannelImpl.finalize()V+1
        v ~StubRoutines::call_stub
        V [libjvm.so+0x610e9c]
        V [libjvm.so+0x659520]
        V [libjvm.so+0x67a82c]
        C [libjava.so+0xc804] Java_java_lang_ref_Finalizer_invokeFinalizeMethod+0x7c
        j java.lang.ref.Finalizer.invokeFinalizeMethod(Ljava/lang/Object;)V+0
        j java.lang.ref.Finalizer.invokeFinalizeMethod(Ljava/lang/Object;)V+0
        j java.lang.ref.Finalizer.runFinalizer()V+45
        j java.lang.ref.Finalizer.access$100(Ljava/lang/ref/Finalizer;)V+1
        j java.lang.ref.Finalizer$FinalizerThread.run()V+11
        v ~StubRoutines::call_stub
        V [libjvm.so+0x610e9c]
        V [libjvm.so+0x60f014]
        V [libjvm.so+0x60f1c8]
        Verr: java.net.SocketException: Too many open files [libjvm.so+0x7f0764]
        V [libjvm.so+0xee91c0]
        V [libjvm.so+0xcb1fa4]


        Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
        j sun.nio.ch.FileDispatcher.preClose0(Ljava/io/FileDescriptor;)V+0
        j sun.nio.ch.DatagramDispatcher.preClose(Ljava/io/FileDescriptor;)V+1
        j sun.nio.ch.DatagramChannelImpl.implCloseSelectableChannel()V+14
        j java.nio.channels.spi.AbstractSelectableChannel.implCloseChannel()V+1
        j java.nio.channels.spi.AbstractInterruptibleChannel.close()V+23
        j sun.nio.ch.DatagramChannelImpl.finalize()V+1
        v ~StubRoutines::call_stub
        j java.lang.ref.Finalizer.invokeFinalizeMethod(Ljava/lang/Object;)V+0
        j java.lang.ref.Finalizer.runFinalizer()V+45
        j java.lang.ref.Finalizer.access$100(Ljava/lang/ref/Finalizer;)V+1
        j java.lang.ref.Finalizer$FinalizerThread.run()V+11
        v ~StubRoutines::call_stub

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

        Java Threads: ( => current thread )
          0x001b1000 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=13]
          0x001ae800 JavaThread "CompilerThread1" daemon [_thread_blocked, id=12]
          0x001ad000 JavaThread "CompilerThread0" daemon [_thread_blocked, id=11]
          0x001ab800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=10]
        =>0x00191000 JavaThread "Finalizer" daemon [_thread_in_vm, id=9]
          0x0018cc00 JavaThread "Reference Handler" daemon [_thread_blocked, id=8]
          0x00046c00 JavaThread "main" [_thread_in_vm, id=2]

        Other Threads:
          0x00188c00 VMThread [id=7]
          0x001b3400 WatcherThread [id=14]

        VM state:not at safepoint (normal execution)

        err: java.net.SocketException: Too many open files
        VM Mutex/Monitor currently owned by a thread: None

        Heap
         PSYoungGen total 10752K, used 873Kerr: java.net.SocketException: Too many open files
         [0xf0000000, 0xf0c00000, 0xfac00000)
          edenerr: java.net.SocketException: Too many open files
         space 9216K, 6% used [0xf0000000,0xf00bd5a0,0xf0900000)
        err: java.net.SocketException: Too many open files from space 1536K, 20% used [0xf0a80000,0xf0ad0040,0xf0c00000)
          to space 1536K, 0% used [0xf0900000,0xf0900000,0xf0a80000)

        err: java.net.SocketException: Too many open files
        err: java.net.SocketException: Too many open files PSOldGen total 24576K, used 0K
         [0xda800000, 0xdc000000, 0xf0000000)
          object space 24576K, 0% used [0xda800000,0xda800000,0xdc000000)
        err: java.net.SocketException: Too many open files
         PSPermGen total 16384K, used 2239K [0xd6800000, 0xd7800000, 0xda800000)
          object space 16384K, 13% used [0xd6800000,0xd6a2fe68,0xd7800000)

        Dynamic libraries:
        0x00010000 /net/mizu.sfbay/n/dolphin/jdk7/binaries/solaris-sparc/b03-2006-11-27/jdk1.7.0/fastdebug/bin/java
        0xff3f8000 /lib/libthread.so.1
        0xff370000 /net/mizu.sfbay/n/dolphin/jdk7/binaries/solaris-sparc/b03-2006-11-27/jdk1.7.0/fastdebug/bin/../jre/lib/sparc/jli/libjli.so
        0xff3a0000 /lib/libdl.so.1
        0xff200000 /lib/libc.so.1
        0xff358000 /platform/SUNW,Ultra-80/lib/libc_psr.so.1
        0xfd400000 /net/mizu.sfbay/n/dolphin/jdk7/binaries/solaris-sparc/b03-2006-11-27/jdk1.7.0/fastdebug/jre/lib/sparc/server/libjvm.so
        0xff320000 /lib/libsocket.so.1
        0xff350000 /usr/lib/libsched.so.1
        0xff1d0000 /lib/libm.so.1
        0xff1a0000 /usr/lib/libCrun.so.1
        0xff1f0000 /lib/libdoor.so.1
        0xff080000 /lib/libnsl.so.1
        0xfd300000 /lib/libm.so.2
        0xff160000 /lib/libscf.so.1
        0xff060000 /lib/libuutil.so.1
        0xfd3d0000 /lib/libmd.so.1
        0xfd2e0000 /platform/SUNW,Ultra-80/lib/libmd_psr.so.1
        0xfd2c0000 /lib/libmp.so.2
        0xfd210000 /net/mizu.sfbay/n/dolphin/jdk7/binaries/solaris-sparc/b03-2006-11-27/jdk1.7.0/fastdebug/jre/lib/sparc/native_threads/libhpi.so
        0xfd140000 /net/mizu.sfbay/n/dolphin/jdk7/binaries/solaris-sparc/b03-2006-11-27/jdk1.7.0/fastdebug/jre/lib/sparc/libverify.so
        0xfd0f0000 /net/mizu.sfbay/n/dolphin/jdk7/binaries/solaris-sparc/b03-2006-11-27/jdk1.7.0/fastdebug/jre/lib/sparc/libjava.so
        0xfd0c0000 /net/mizu.sfbay/n/dolphin/jdk7/binaries/solaris-sparc/b03-2006-11-27/jdk1.7.0/fastdebug/jre/lib/sparc/libzip.so
        0xfd070000 /net/mizu.sfbay/n/dolphin/jdk7/binaries/solaris-sparc/b03-2006-11-27/jdk1.7.0/fastdebug/jre/lib/sparc/libnet.so
        0xfd050000 /net/mizu.sfbay/n/dolphin/jdk7/binaries/solaris-sparc/b03-2006-11-27/jdk1.7.0/fastdebug/jre/lib/sparc/libnio.so
        0xff190000 /lib/librt.so.1

        VM Arguments:
        java_command: FdBugTest
        Launcher Type: SUN_STANDARD

        Environment Variables:
        JAVA_HOME=/java/re/jdk/7/nightly/binaries/solaris-sparc/latest/fastdebug
        PATH=/home/tbell/bin/sparc/5.11:/home/tbell/bin/sparc:/home/tbell/bin:/java/re/jdk/7/nightly/binaries/solaris-sparc/latest/fastdebug/bin:/java/re/jdk/7/nightly/binaries/solaris-sparc/latest/fastdebug/bin/sparcv9:/usr/dt/bin:/usr/openwin/bin:/usr/bin:/usr/sbin:/java/devtools/sparc/teamware/7.7/bin:/java/devtools/sparc/SUNWspro/SS11/bin:/java/devtools/sparc/bin:/java/devtools/sparc/gnucc/bin:/usr/ccs/bin:/sbin:.:/usr/sfw/bin:/opt/sfw/bin:/usr/local/bin:/usr/ucb
        LD_LIBRARY_PATH=/net/mizu.sfbay/n/dolphin/jdk7/binaries/solaris-sparc/b03-2006-11-27/jdk1.7.0/fastdebug/jre/lib/sparc/server:/net/mizu.sfbay/n/dolphin/jdk7/binaries/solaris-sparc/b03-2006-11-27/jdk1.7.0/fastdebug/jre/lib/sparc:/net/mizu.sfbay/n/dolphin/jdk7/binaries/solaris-sparc/b03-2006-11-27/jdk1.7.0/fastdebug/jre/../lib/sparc:/usr/lib/sam/lib:/usr/lib/dc:/usr/lib/breg:/usr/sfw/lib:
        SHELL=/bin/csh
        DISPLAY=:0.0
        HOSTTYPE=sun4
        OSTYPE=solaris
        MACHTYPE=sparc

        Signal Handlers:
        SIGSEGV: [libjvm.so+0x10309fc], sa_mask[0]=0xffbffeff, sa_flags=0x0000000c
        SIGBUS: [libjvm.so+0x10309fc], sa_mask[0]=0xffbffeff, sa_flags=0x0000000c
        SIGFPE: [libjvm.so+0xcbb04c], sa_mask[0]=0xffbffeff, sa_flags=0x0000000c
        SIGPIPE: [libjvm.so+0xcbb04c], sa_mask[0]=0xffbffeff, sa_flags=0x0000000c
        SIGILL: [libjvm.so+0xcbb04c]err: java.net.SocketException: Too many open files, sa_mask[0]=0xffbffeff, sa_flags=0x0000000c
        SIGUSR1: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000
        SIGUSR2: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000
        SIGHUP:
        [libjvm.so+0xcb55c0], sa_mask[0]=0xffbffeff, sa_flags=0x00000004
        SIGINT: [libjvm.so+0xcb55c0], sa_mask[0]=0xffbffeff, sa_flags=0x00000004
        SIGQUIT: [libjvm.so+0xcb55c0], sa_mask[0]=0xffbffeff, sa_flags=0x00000004
        SIGTERM: [libjvm.so+0xcb55c0], sa_mask[0]=0xffbffeff, sa_flags=0x00000004
        SIGQUIT: [libjvm.so+0xcb55c0], sa_mask[0]=0xffbffeff, sa_flags=0x00000004
        SIGTERM: [libjvm.so+0xcb55c0], sa_mask[0]=0xffbffeff, sa_flags=0x00000004
        SIG39: [libjvm.so+0xcbb06c], sa_mask[0]=0x00000000, sa_flags=0x00000008
        SIG40: [libjvm.so+0xcbb04c], sa_mask[0]=0xffbffeff, sa_flags=0x0000000c


        --------------- S Y S T E M ---------------

        OS:Solaris
        uname:err: java.net.SocketException: Too many open filesSunOS 5.11 snv_49 sun4u (T2 libthread)
        rlimit: STACK 8192k, CORE infinity, NOFILE 1024, AS infinity
        load average:
        0.07 0.13 0.14

        CPU:total 4 has_v8, has_v9, has_vis1

        Memory: 8k page, physical 2097152k(55392k free)

        vm_info: Java HotSpot(TM) Server VM (1.7.0-ea-fastdebug-b03) for solaris-sparc, built on Nov 27 2006 03:21:05 by "" with unknown Workshop:0x580

        #
        # If you would like to submit a bug report, please visit:
        # http://java.sun.com/webapps/bugreport/crash.jsp
        #
        Current thread is 9
        Dumping core ...

        Attachments

          Issue Links

            Activity

              People

                alanb Alan Bateman
                tbell Tim Bell
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: