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

(linux|bsd|aix)_close.c: file descriptor table may become large or may not work at all

    Details

    • Subcomponent:
    • Resolved In Build:
      b116
    • OS:
      linux, os_x, aix

      Backports

        Description

        In linux_close.c - and similarily in bsd_close.c and aix_close.c - an array (fdTable) is used to keep an information record and a mutex per opened file descriptor. This array gets allocated at the start of the process.

        In order to guess on the size of the table, getrlimit(RLIMIT_NO_FILE) is used.

        There are some problems with this approach:

        1) There is no handling for an infinite limit. Depending on what the numerical value is for RLIM_INFINITY, allocation of the file descriptor table may fail at this point (RLIM_INFINITY=-1) or be very small (RLIM_INFINITY=0). This may lead to file descriptors not covered by the whole wakeup mechanism implemented in this file, and hence to hanging threads.

        2) For large - but not infinite - values of RLIMIT_NO_FILE, the memory usage is excessive. On Linux x64, each entry in the table is ~ 50Bytes; for a limit of 1000000, this eats up 50MB. Most of this memory is usually never used.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  stuefe Thomas Stuefe
                  Reporter:
                  stuefe Thomas Stuefe
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  9 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: