Subject: Re: bug#10470: MSYS: race in directory access?

From: Stefano Lattarini <[email-masked]>
Date: Fri, 13 Jan 2012 10:05:55 +0100

On 01/12/2012 11:39 AM, Peter Rosin wrote:
>
> After digging out that the patches are for maint,
>
Oops, sorry I didn't state that explicitly!

> I managed to commit them,
> but FYI this bugfix is only needed on master.
>
True, but I'd rather avoid code divergences if possible and if that doesn't
cause performance regressions (conditions which both hold in this case).

> AM_SANITY_CHECK is not
> aggressive enough on maint to cause problems, as can be seen below.  But ok
> to commit wherever, it behaves as designed. Thanks!
>
Thanks to you for the patient analysis and testing.

> I should also add that it's a POSIX violation to assume that directory
> removal works when the dir is the CWD of a process.
> 
> 	"If the directory is the root directory or the current working
> 	directory of any process, it is unspecified whether the function
> 	succeeds, or whether it shall fail and set errno to [EBUSY]."
> 
Good to know.  I've amended the git commit message of the second patch
accordingly, to read as follows:

    dist: avoid $(distdir) removal failure on MSYS/MinGW

    This change fixes automake big#10470.

    On MSYS (1.0.17) it is not possible to remove a directory that is
    in use, and this, together with timing issues, could cause spurious
    failures in the cleanup code of the "distcheck" recipe.  In fact,
    it should be noted that assuming a directory can be removed while
    it the CWD of a running process is a POSIX violation:

      "If the directory is the root directory or the current working
       directory of any process, it is unspecified whether the function
       succeeds, or whether it shall fail and set errno to [EBUSY]."

    * lib/am/distdir.am (am__remove_distdir): If rm fails, sleep some
    seconds and retry, to give potential "pending" processes some time
    to exit and "release" the directory.
    * tests/Makefile.am (XFAIL_TESTS): Remove 'distcheck-pr10470.test'.

    Report and suggestions by Peter Rosin and Eric Blake.

I will push by this evening or tomorrow if there is no objection.

Thanks,
  Stefano