bugmake - Bugs: bug #26075, $(wildcard) function holds parent...

 
 

bug #26075: $(wildcard) function holds parent directories open preventing deletes

Submitter:  Peter Halliday <centraspike>
Submitted:  Fri 03 Apr 2009 09:33:42 AM UTC
Votes: 1
 
Severity:  3 - Normal Item Group:  Bug
Status:  Works for me Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  3.81 Operating System:  MS Windows
Fixed Release:  4.0 Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 21 Oct 2013 08:43:36 AM UTC, comment #7: 

I cannot reproduce this with Make 4.0 compiled with MinGW.  Not only don't I see the error message, I also see closedir being called for each opendir.

So either the problem was fixed (perhaps inside glob.c, when it was updated from upstream), or something else is required to reproduce the problem.

I'm closing the bug; feel free to reopen if new data is available that allows to reproduce this.

Eli Zaretskii <eliz>
Group Member
Sat 04 Apr 2009 01:11:28 AM UTC, comment #6: 

Couldn't find the data but the "dir-.c" I was using to get them. Attached without any warranty. Use instead of dir.c.

(file #17863)

Anonymous
Sat 04 Apr 2009 12:10:09 AM UTC, comment #5: 

Hm, that's interesting.  There's no doubt that the directory cache causes unexpected consequences when your makefile does things "behind the scenes" that make doesn't know about (so it can't update the cache appropriately).

However, this is the first time I've ever heard the assertion that it is actually slower than no cache at any time, much less on average, or by magnitudes.

I'm not saying you're wrong, because I've never tested it myself.  But, do you have any hard data to prove this assertion?

Paul D. Smith <psmith>
Group administrator
Fri 03 Apr 2009 11:58:36 PM UTC, comment #4: 

Actually that directory cache is just crap.  Not only that it causes several bad sideeffects (like new files not being noticed) but actually is slower on average than no cache at all, in cases slowser by magnitudes.

Anonymous
Fri 03 Apr 2009 09:21:30 PM UTC, comment #3: 

If you use "strace" you will see the same problem on Ubuntu - but you won't see "rm" throw an error because the Linux file system you are using allows directories to be unlinked even if they are in use.

This is still a bug, though, even though it isn't obvious on some systems.

Anonymous
Fri 03 Apr 2009 01:28:35 PM UTC, comment #2: 

I think I have a fix for this issue (at least it's working for me with my makefiles). I have edited dir.c to limit the maximum number of open directories under windows to just 1 (normally it is 10) this results in directories being closed straight away after caching contents. The change is to replace the following line:


#define MAX_OPEN_DIRECTORIES 1


with:


#ifdef WINDOWS32
/*
        Under windows holding directories open at all can cause problems as it prevents them being deleted.
        For instance in this makefile example the clean target will fail as the build directory will be locked by the make process as a result of the wildcard test:

        all: $(filter-out $(wildcard build\release), build\release)

        build\release:
                mkdir build\release

        clean:
                rmdir /Q /S build

        This may be an NTFS specific problem but I have not yet checked this on a Fat file system.
*/
# define MAX_OPEN_DIRECTORIES 1
#else
# define MAX_OPEN_DIRECTORIES 10
#endif


I have also attached my version of dir.c

(file #17859)

Peter Halliday <centraspike>
Fri 03 Apr 2009 09:43:02 AM UTC, comment #1: 

I've just tried the same construct on Ubuntu where it works just fine so it does seems to be windows specific. I'm currently digging through the source to see if i've forgotten to set some flag at compile time or if i can see the error but so far i haven't found anything.

Peter Halliday <centraspike>
Fri 03 Apr 2009 09:33:42 AM UTC, original submission:  

Apologies for the windows stuff but the following makefile clean target does not work:

all: $(filter-out $(wildcard build\release), build\release)

build\release:
mkdir build\release

clean:
rmdir /Q /S build

First do gmake all then try gmake clean. The following error occurs:

rmdir /Q /S build
The process cannot access the file because it is being used by another process.
gmake: * [clean] Error 32

I have managed to trace the cause to the fact that the wildcard function opens a handle to the build directory in order to check if the release directory exists and then does not release the handle till gmake exits

Peter Halliday <centraspike>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #17863:  dir-.c added by None (5KiB - text/plain - dir.c w/o cache (for testing purposes))
file #17859:  dir.c added by centraspike (31KiB - text/plain - Modified dir.c to prevent directory locks on windows)
file #17857:  makefile added by centraspike (131B - application/octet-stream - Example makefile)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by eliz (Posted a comment)
  • -email is unavailable- added by jbezem (Voted in favor of this item)
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by centraspike (Submitted the item)
  •  

    There is 1 vote so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-10-21 eliz StatusNone Works for me
        Open/ClosedOpen Closed
        Fixed ReleaseNone 4.0
    2009-04-16 jbezem Carbon-Copy- Added jbezem
    2009-04-04 None Attached File- Added dir-.c, #17863
    2009-04-03 centraspike Attached File- Added dir.c, #17859
    2009-04-03 centraspike Attached File- Added makefile, #17857

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code