On cygwin perl (at least), here's a fun bug especially in multi-process scenarios.
1. Open a file for writing. Don't close it.
2. Use rmtree to delete the directory the file resides in. Ignore the error.
3. Close the filehandle created in step #1
4. Repeat step 2 (delete the directory again - it will work this time)
5. Create the deleted directory again using mkpath. The attempt will succeed but the directory actually won't exist.
6. Create a file in the directory created in step 5
Result: Error - permission denied, because its directory doesn't exist.