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

DefaultFileManager may throw "could not create parent directories" in concurrent execution

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b09
    • CPU:
      generic
    • OS:
      solaris, windows_vista
    • Verification:
      Verified

      Description

      We faced with "could not create parent directories" exception during the concurrent file compilation on the fast multi-cpu machine. If seems that the problem exists in the com.sun.tools.javac.util.DefaultFileManager. Let's consider the code below:
      ...
      private void ensureParentDirectoriesExist() throws IOException {
                  if (!hasParents) {
                      File parent = f.getParentFile();
                      if (parent != null && !parent.exists()) {
                      //point #1
                          if (!parent.mkdirs()) {
      //point #2
                              throw new IOException("could not create parent directories");
                          }
                      }
                      hasParents = true;
                  }
      }
      ...
      Let's imagine the we are compiling two classes a.b.c.d.e.Cl and a.b.c.d.C2 in parallel and directory a/b/c/d/e has not been created yet. Processes 1 and 2 steps on point #1 simultaneously. The one of the processes creates the directory structure, for example 'a/b/c/d' and returns successfully. At the same moment other process invokes parent.mkdirs() and gets false becase some subdiretories has been already created by the process 1. As a result process 2 steps on point #2 and throws an exception.
      I have reporoduced this problem using dmake. Please see /home/ag153348/tmp/compiler_bug/Makefile.

      Command output for concurrent mode:
      ----------------------------------
      ag153348@oink$ rm -rf classes; dmake all
      dmake: defaulting to parallel mode.
      See the man page dmake(1) for more information on setting up the .dmakerc file.
      oink --> 1 job
      /java/re/jdk/6/latest/binaries/solaris-sparc/bin/javac -d classes C1.java
      oink --> 2 jobs
      /java/re/jdk/6/latest/binaries/solaris-sparc/bin/javac -d classes C2.java
      oink --> Job output
      /java/re/jdk/6/latest/binaries/solaris-sparc/bin/javac -d classes C2.java
      C2.java:2: error while writing a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.C2: could not create parent directories
      class C2 {
      ^
      1 error
      *** Error code 1
      dmake: Fatal error: Command failed for target `C2.ok'
      Waiting for 1 job to finish
      -------------------------------
      Command output for single job mode:
      ----------------------------------
      ag153348@oink$ rm -rf classes; dmake -j 1 all
      dmake: defaulting to parallel mode.
      See the man page dmake(1) for more information on setting up the .dmakerc file.
      oink --> 1 job
      /java/re/jdk/6/latest/binaries/solaris-sparc/bin/javac -d classes C1.java
      oink --> 1 job
      /java/re/jdk/6/latest/binaries/solaris-sparc/bin/javac -d classes C2.java
      ag153348@oink$
      ----------------------------------------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jjg Jonathan Gibbons
              Reporter:
              agavrilosunw Alexey Gavrilov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: