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

Use open(O_CLOEXEC) instead of fcntl(FD_CLOEXEC)

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b40
    • OS:
      linux
    • Verification:
      Not verified

      Backports

        Description

        JDK should use O_CLOEXEC when available; faster and less racy than FD_CLOEXEC.

        O_CLOEXEC is standardized.
        http://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html

        Backward compatibility needs to be provided via #ifdef and checking (once) whether O_CLOEXEC works.

        All the Unix variants should have very similar changes to their os::open code applied.

        Webrev: http://cr.openjdk.java.net/~martin/webrevs/openjdk9/O_CLOEXEC/

          Activity

          martin Martin Buchholz created issue -
          twisti Christian Thalinger made changes -
          Field Original Value New Value
          Status New [ 10000 ] Open [ 1 ]
          twisti Christian Thalinger made changes -
          Affects Version/s 9 [ 14949 ]
          Hide
          twisti Christian Thalinger added a comment -
          I think this should be an Enhancement rather than a Bug.
          Show
          twisti Christian Thalinger added a comment - I think this should be an Enhancement rather than a Bug.
          martin Martin Buchholz made changes -
          Issue Type Bug [ 1 ] Enhancement [ 7 ]
          ctornqvi Christian Tornqvist made changes -
          Status Open [ 1 ] New [ 10000 ]
          ctornqvi Christian Tornqvist made changes -
          Fix Version/s 9 [ 14949 ]
          ctornqvi Christian Tornqvist made changes -
          Status New [ 10000 ] Open [ 1 ]
          Hide
          martin Martin Buchholz added a comment -
          I think it's a Bug. There's an obscure race if a subprocess is created by native code somewhere and a fd leaks into the subprocess before the call to fcntl, causing possible hangs with open filedescriptors. Essentially, any time a multi-threaded app used FD_CLOEXEC instead of O_CLOEXEC, it introduces a bug.

          I have a webrev - how do we make progress? I can check in the linux code first, which is in production use locally, and leave ports to other platforms to y'all?
          Show
          martin Martin Buchholz added a comment - I think it's a Bug. There's an obscure race if a subprocess is created by native code somewhere and a fd leaks into the subprocess before the call to fcntl, causing possible hangs with open filedescriptors. Essentially, any time a multi-threaded app used FD_CLOEXEC instead of O_CLOEXEC, it introduces a bug. I have a webrev - how do we make progress? I can check in the linux code first, which is in production use locally, and leave ports to other platforms to y'all?
          Hide
          twisti Christian Thalinger added a comment -
          That should be fine. Did you send a review to the mailing list yet?
          Show
          twisti Christian Thalinger added a comment - That should be fine. Did you send a review to the mailing list yet?
          Hide
          martin Martin Buchholz added a comment -
          Yes, message to hotspot-runtime-dev here:
          http://markmail.org/message/37fkwpv6ajt7ae2x
          Show
          martin Martin Buchholz added a comment - Yes, message to hotspot-runtime-dev here: http://markmail.org/message/37fkwpv6ajt7ae2x
          Hide
          twisti Christian Thalinger added a comment -
          Long time ago and no reply. Ping the list.
          Show
          twisti Christian Thalinger added a comment - Long time ago and no reply. Ping the list.
          Hide
          martin Martin Buchholz added a comment -
          Fixed deployed locally in production on Linux; ports to other platforms should be relatively easy, but we can't test them.
          Show
          martin Martin Buchholz added a comment - Fixed deployed locally in production on Linux; ports to other platforms should be relatively easy, but we can't test them.
          martin Martin Buchholz made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Understanding Fix Understood [ 10001 ]
          Hide
          martin Martin Buchholz added a comment -
          See also
          https://sourceware.org/bugzilla/show_bug.cgi?id=10353
          where Uli Drepper encourages everyone to switch to O_CLOEXEC ASAP, in his own inimitable style.
          Show
          martin Martin Buchholz added a comment - See also https://sourceware.org/bugzilla/show_bug.cgi?id=10353 where Uli Drepper encourages everyone to switch to O_CLOEXEC ASAP, in his own inimitable style.
          Hide
          martin Martin Buchholz added a comment -
          jdk9 sources have changed, so I had to adjust the webrev.

          Show
          martin Martin Buchholz added a comment - jdk9 sources have changed, so I had to adjust the webrev.
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/hs-rt/hotspot/rev/6fc3b8261368
          User: dholmes
          Date: 2014-10-29 04:45:35 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/hs-rt/hotspot/rev/6fc3b8261368 User: dholmes Date: 2014-10-29 04:45:35 +0000
          hgupdate HG Updates made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Understanding Fix Understood [ 10001 ]
          Resolved In Build team [ 17324 ]
          Resolution Fixed [ 1 ]
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/6fc3b8261368
          User: lana
          Date: 2014-11-17 19:26:14 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/6fc3b8261368 User: lana Date: 2014-11-17 19:26:14 +0000
          hgupdate HG Updates made changes -
          Resolved In Build team [ 17324 ] master [ 18256 ]
          hgupdate HG Updates made changes -
          Resolved In Build master [ 18256 ] b40 [ 17439 ]
          ctornqvi Christian Tornqvist made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Verification Not verified [ 17001 ]
          hgupdate HG Updates made changes -
          Link This issue backported by JDK-8083477 [ JDK-8083477 ]

            People

            • Assignee:
              martin Martin Buchholz
              Reporter:
              martin Martin Buchholz
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: