autoconf-patches
[Top][All Lists]
Advanced

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

Re: avoid spurious failures from MacOS readdir bug


From: Eric Blake
Subject: Re: avoid spurious failures from MacOS readdir bug
Date: Tue, 2 Dec 2008 18:58:37 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Eric Blake <ebb9 <at> byu.net> writes:

> 
> As reported by various people, most recently by Bruce Dugan, the autoconf 
> testsuite has spurious failures on MacOS 10.5, where readdir intermittently 
> lists a file more than once in the face of a rapidly changing directory.

What do people think of this followup patch?

Is 'ls -1' really non-portable, or is the manual missing '1' from its list of 
portable options?  Is there any known ls where 'ls -1 | blah' and 'ls | blah' 
behave differently?

Also, does this attempt to shave processes in the autoconf testsuite look 
valid?  [Lest you get a mistaken idea about my abilities, my sed-foo isn't that 
strong: I had to copy liberally from the 'info sed' manual.]


From: Eric Blake <address@hidden>
Date: Tue, 2 Dec 2008 11:51:44 -0700
Subject: [PATCH] Improve AC_STATE_SAVE.

* tests/local.at (AC_STATE_SAVE): Avoid ls -1, use one less
process by hoisting the uniqueness check into sed.
* doc/autoconf.texi (Limitations of Usual Tools) <ls>: Mention
MacOS bug.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog         |    6 ++++++
 doc/autoconf.texi |   10 ++++++++++
 tests/local.at    |   16 ++++++++++++++--
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7ca53e9..e585861 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2008-12-02  Eric Blake  <address@hidden>
 
+       Improve AC_STATE_SAVE.
+       * tests/local.at (AC_STATE_SAVE): Avoid ls -1, use one less
+       process by hoisting the uniqueness check into sed.
+       * doc/autoconf.texi (Limitations of Usual Tools) <ls>: Mention
+       MacOS bug.
+
        Avoid MacOS readdir bug in testsuite.
        * tests/local.at (AC_STATE_SAVE): Avoid spurious failures due to
        duplicated ls entries.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 1decd4b..fe28f39 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -16575,6 +16575,16 @@ Limitations of Usual Tools
 @samp{.c} files.  This is no longer a practical problem, since current
 @command{ls} implementations send diagnostics to standard error.
 
+The behavior of @command{ls} on a directory that is being concurrently
+modified is not always predictable, because of a data race where cached
+information returned by @code{readdir} does not match the current
+directory state.  In fact, MacOS 10.5 has an intermittent bug where
address@hidden, and thus @command{ls}, sometimes lists a file more than
+once if other files were added or removed from the directory immediately
+prior to the @command{ls} call.  Since @command{ls} already sorts its
+output, the duplicate entries can be avoided by piping the results
+through @code{uniq}.
+
 @anchor{mkdir}
 @item @command{mkdir}
 @c ------------------
diff --git a/tests/local.at b/tests/local.at
index 2ec7bc5..fa9cef1 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -197,11 +197,23 @@ m4_define([AT_CONFIGURE_AC],
 # confirm that no test modifies variables outside the Autoconf namespace or
 # leaves temporary files.  AT_CONFIG_CMP uses the variable dumps to confirm 
that
 # tests have the same side effects regardless of caching.
-# The sort -u is necessary, since MacOS 10.5 has a bug where readdir can
+# The sed script duplicates uniq functionality (thanks to 'info sed' for
+# the recipe), to avoid a MacOS 10.5 has a bug where readdir can
 # list a file multiple times in a rapidly changing directory.
 m4_defun([AC_STATE_SAVE],
 [(set) 2>&1 | sort >state-env.$][1
-ls -1 | sed '/^at-/d;/^state-/d;/^config\./d' | sort -u >state-ls.$][1
+ls | sed '/^at-/d;/^state-/d;/^config\./d
+  h
+  :b
+  $b
+  N
+  /^\(.*\)\n\1$/ {
+    g
+    bb
+  }
+  $b
+  P
+  D' >state-ls.$][1
 ])# AC_STATE_SAVE
 ]])
 
-- 
1.6.0.4







reply via email to

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