Bug 208093

Summary: install -d race
Product: Base System Reporter: Matt Johnston <matt>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Some People    
Priority: ---    
Version: 10.3-BETA2   
Hardware: Any   
OS: Any   

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.

#!/bin/sh

while true; do

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

done


output:
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.