Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#5184 closed bug (fixed)

createDirectory does not retry on EINTR (interrupted)

Reported by: CoreyOConnor Owned by: simonmar
Priority: high Milestone: 7.2.1
Component: libraries/unix Version: 7.0.3
Keywords: Cc: pho@…
Operating System: MacOS X Architecture: x86
Type of failure: Incorrect result at runtime Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


With GHC 7.0.3 on Mac OS X 32bit the createDirectory call does not retry if the call is interrupted. I would expect the call to be retried.

Unfortunately, I have not determined a small test program for this bug. This is the output from when this issue occurs:

/home/coconnor/Development/dev-system: createDirectory: interrupted (Interrupted system call)

Interestingly the directory indicated by this output does not match the directory requested to be created. The program calls:

createDirectoryIfMissing True "/home/coconnor/Development/dev-system/build/"

And it is known, at the time, that the directory "/home/coconnor/Development/dev-system" exists. Perhaps the method checking for if a directory exists is also receiving EINTR?

This same program works as expected on linux 32bit & 64bit using GHC 7.0.3.

Change History (6)

comment:1 Changed 9 years ago by PHO

Cc: pho@… added

comment:2 Changed 9 years ago by simonmar

Milestone: 7.2.1
Owner: set to simonmar
Priority: normalhigh

The POSIX spec doesn't say that mkdir can return EINTR, so I suppose OS X is non-standard here. I'll fix it in System.Posix.Directory anyway.

comment:3 Changed 9 years ago by simonmar

Resolution: fixed
Status: newclosed

comment:4 Changed 9 years ago by CoreyOConnor

I think there is a deeper issue here and the EINTR error might just be a red herring.

I still cannot create directories with "createDirectoryIfMissing True" as expected. I'm going to leave my comments attached to this bug for now.

In my application I call:

createDirectoryIfMissing True "/home/coconnor/Development/dev-system/dist/build"

on a system where "/home/coconnor/Development/dev-system/dist" already exists. Instead of creating the "build' directory under "dist" as expected the application fails with:

dev: /home/coconnor: createDirectory: failed (Operation not supported)

It does not make sense that "createDirectory" would ever be called with an existing directory by "createDirectoryIfMissing".

I'm not sure how this can occur. If there was a bug in getFileStatus or isDirectory then this could occur.

The only thing I can think of has a weak argument. The stat structure on OS X comes in two varieties. The define _DARWIN_FEATURE_64_BIT_INODE is used to select between the two varieties. If the fstat call used at runtime expects a different stat structure than System/Posix/Files.hsc is compiled against then getFileStatus can succeed but the status would be junk.

comment:5 Changed 9 years ago by CoreyOConnor

c_stat (the equation eventually used by getFileStatus) is defined in base/include/HsBase.h. So the structure offsets in System/Posix/Files.hsc need to be generated from the same stat structure as used by c_stat in base. Perhaps unix and base are using different stat structures.

comment:6 Changed 9 years ago by CoreyOConnor

scratch my previous comments: I did check to make sure the stat structure was consistent between the libraries and, of course, it was.

My issue was unrelated. While I still have no idea how mkdir is returning EINTR, my current issues are all resolved.

Note: See TracTickets for help on using tickets.