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

(se) File descriptor leak when Selector.open fails

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 8u60
    • core-libs
    • b85
    • x86_64
    • linux

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

        ADDITIONAL OS VERSION INFORMATION :
         3.19.0-25-generic #26~14.04.1-Ubuntu SMP

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        ulimit -n
        1024


        A DESCRIPTION OF THE PROBLEM :
        EPollSelectorImpl doesn't close 2 file descriptors (fd0, fd1) if pollWrapper throws exception:

            EPollSelectorImpl(SelectorProvider sp) throws IOException {
                super(sp);
                long pipeFds = IOUtil.makePipe(false);
                fd0 = (int) (pipeFds >>> 32);
                fd1 = (int) pipeFds;
                pollWrapper = new EPollArrayWrapper();
                pollWrapper.initInterrupt(fd0, fd1);
                fdToKey = new HashMap<>();
            }


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
         - Open many file descriptors: MAX_OPEN_FILE-2
         - Try create epoll selector
         - EPollSelectorImpl opens pipe and consume last 2 descriptors
         - EPollSelectorImpl calls epoll_create syscall
         - EPollSelectorImpl throws IOException without closing pipe


        REPRODUCIBILITY :
        This bug can be reproduced rarely.

              igerasim Ivan Gerasimov
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: