Bug 208093 - install -d race
Summary: install -d race
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.3-BETA2
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
Depends on:
Reported: 2016-03-17 16:23 UTC by Matt Johnston
Modified: 2016-03-18 10:28 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Matt Johnston 2016-03-17 16:23:40 UTC
install -d has a race condition between checking for existence and mkdir(). It fails with "File exists". This can be encountered running "make -j" where the same parent directory is created in multiple rules:
install -d /Users/travis/inst/sbin  #these three run at once
install -d /Users/travis/inst/bin
install -d /Users/travis/inst/bin
install: mkdir /Users/travis/inst: File exists

Run two copies of the following to reproduce it. Note that the same problem also exists for intermediate directories, though that's more difficult to reproduce.


while true; do

install -d /tmp/xx123/test
rm -d -f  /tmp/xx123/test


install: mkdir /tmp/xx123/test: File exists
install: mkdir /tmp/xx123/test: File exists
install: mkdir /tmp/xx123/test: File exists
Comment 1 Matt Johnston 2016-03-18 10:28:43 UTC
Looks like this was fixed in http://svnweb.freebsd.org/base?view=revision&revision=272026 but that hasn't made it to 10.3 yet.