Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,385
    • Issues 4,385
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 369
    • Merge Requests 369
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #2924

Closed
Open
Opened Jan 08, 2009 by Simon Marlow@simonmarDeveloper

createDirectory: permission denied

The following program results in an odd "permission denied" error from createDirectory on Windows. It is derived from the createDirectoryIfMIssing001 test, but doesn't involve calling createDirectoryIfMissing, only createDirectory.

There are two threads, each of which is repeatedly creating a directory and using removeDirectoryRecursive to remove it.

Test program:

import System.IO
import System.Directory
import Control.Monad
import Control.Concurrent
import Control.Exception
import System.IO.Error

testdir = "foo"

main = do
  cleanup
  m <- newEmptyMVar
  forkIO $ do replicateM_ 1000 (do create; cleanup); putMVar m ()
  forkIO $ do replicateM_ 1000 (do create; cleanup); putMVar m ()
  replicateM_ 2 $ takeMVar m
  cleanup

create =
  tryJust (guard . isAlreadyExistsError) $ createDirectory testdir

cleanup =
  tryJust (guard . isDoesNotExistError) $ removeDirectoryRecursive testdir

The result is usually:

test.exe: CreateDirectory: permission denied (Access is denied.)

It's not clear (to me at least) why we get this error. Running the program under !ProcMon shows that there is a CreateFile call that returns DELETE PENDING, but as far as I can tell this doesn't give rise to an ERROR_DELETE_PENDING return from CreateDirectory, because that would give a different error message. Perhaps somewhere in the bowels of the Win32 API a DELETE_PENDING is being turned into a permission denied, or something.

This deserves investigation, because I think it might be related to other spurious "permission denied" errors we occasionally see on Windows.

Trac metadata
Trac field Value
Version 6.10.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/directory
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
6.12.3
Milestone
6.12.3
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#2924