autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mkdir doco


From: Alexandre Duret-Lutz
Subject: Re: mkdir doco
Date: Wed, 18 Feb 2004 22:32:17 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

Hi Paul,

>>> "Paul" == Paul Eggert <address@hidden> writes:

 Paul> Alexandre Duret-Lutz <address@hidden> writes:
 >> OK to commit?

 Paul> It seems like a pretty common sort of problem in all
 Paul> sorts of applications.

Yes, sure... but perhaps the patch also lacks some context :)

The context is parallel make.  I think this restrict the range
of applications to consider.  Commands are called concurrently
for different output, so one do not expect the kind of race
described here.  (Especially from good-old-mkdir, I would add.)

The problem emerged during a parallel build of GCC on Solaris 8,
and took a while to figure out (just for this reason I think it
deserves to be documented somewhere).

  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11932

Since then I've checked the source of mkdir in a few other
places.  This behavior is not limited to Solaris (see augmented
patch below).

Within this context, do you still think it should go 
elsewhere?  Where?   


2004-02-18  Alexandre Duret-Lutz  <address@hidden>

        * doc/autoconf.texi (Limitations of Usual Tools) <mkdir>: `mkdir -p'
        is not always thread-safe.  From Nathanael Nerode.

Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.801
diff -u -r1.801 autoconf.texi
--- doc/autoconf.texi   9 Feb 2004 21:19:32 -0000       1.801
+++ doc/autoconf.texi   18 Feb 2004 20:56:21 -0000
@@ -11273,6 +11273,21 @@
 directory.  GNU Coreutils 5.1.0 @command{mkdir} succeeds, but Solaris 9
 @command{mkdir} fails.
 
+Not all @code{mkdir -p} implementations are thread-safe.  When it is not
+and you call @code{mkdir -p a/b} and @code{mkdir -p a/c} at the same
+time, both will detect that @file{a/} is missing, one will create
address@hidden/}, then the other will try to create @file{a/} and die with a
address@hidden exists} error.  At least Solaris 8, NetBSD 1.6, and OpenBSD
+3.4 have an unsafe @code{mkdir -p}.  GNU Coreutils (since version 3.16),
+FreeBSD 5.0, and NetBSD-current are known to have a race-free
address@hidden -p}.  This possible race is harmful in parallel builds when
+several @file{Makefile} rules call @code{mkdir -p} to construct
+directories.  You may use @command{mkinstalldirs} or @code{install-sh
+-d} as a safe replacement, provided these scripts are recent enough (the
+copies shipped with Automake 1.8.3 are OK, those from older versions are
+not thread-safe either).
+
+
 @item @command{mv}
 @c ---------------
 @prindex @command{mv}

-- 
Alexandre Duret-Lutz





reply via email to

[Prev in Thread] Current Thread [Next in Thread]