Thread overview
[Issue 4396] New: mkdir race prevents concurrent compiling with DMD using make -j
Jun 27, 2010
Leandro Lucarella
Jun 29, 2010
Walter Bright
Jun 29, 2010
Leandro Lucarella
Jul 01, 2010
Gide Nwawudu
Jul 01, 2010
Walter Bright
June 27, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4396

           Summary: mkdir race prevents concurrent compiling with DMD
                    using make -j
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: patch
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: llucax@gmail.com


--- Comment #0 from Leandro Lucarella <llucax@gmail.com> 2010-06-27 07:10:43 PDT ---
Since DMD creates directories as needed, when using make -j to compile some modules concurrently, if 2 modules lives in the same directory, that directory doesn't exist and both are compiled at the same time, there are times where this set of steps are performed:

1) dmd m1.d checks if dstdir exist (it doesn't)
2) dmd m2.d checks if dstdir exist (it doesn't)
3) dmd m1.d creates dstdir successfully
4) dmd m2.d tries to create dstdir but it fails because dmd m1.d already
created it.

Here is a simple patch. Created against D1 svn but I guess it will apply to D2 cleanly also.

---
diff --git a/src/root/root.c b/src/root/root.c
index 3d491a4..9df951c 100644
--- a/src/root/root.c
+++ b/src/root/root.c
@@ -957,7 +957,10 @@ void FileName::ensurePathExists(const char *path)
 #if POSIX
                 if (mkdir(path, 0777))
 #endif
-                    error("cannot create directory %s", path);
+                {
+                    if (errno != EEXIST)
+                        error("cannot create directory %s", path);
+                }
             }
         }
     }
---

I'm not sure how the mkdir() API for windows behaves regarding errno, I
couldn't find any reference of mkdir() for windows.

Adding a strerror() to the error message could be useful too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 29, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4396


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2010-06-29 09:33:25 PDT ---
http://www.dsource.org/projects/dmd/changeset/568

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 29, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4396



--- Comment #2 from Leandro Lucarella <llucax@gmail.com> 2010-06-29 10:32:22 PDT ---
Thanks!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 01, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4396


Gide Nwawudu <gide@nwawudu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |gide@nwawudu.com
         Resolution|FIXED                       |


--- Comment #3 from Gide Nwawudu <gide@nwawudu.com> 2010-07-01 00:16:31 PDT ---
Commit 569 reverted the change.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 01, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4396


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2010-07-01 10:57:31 PDT ---
http://www.dsource.org/projects/dmd/changeset/570

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------