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

(se) File descriptor leak when Selector.open fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u60
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b85
    • CPU:
      x86_64
    • OS:
      linux

      Backports

        Description

        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.

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved: