Opened 11 years ago

Closed 11 years ago

Last modified 9 years ago

#891 closed bug (fixed)

hsc2hs tries to remove an open file

Reported by: eivuokko Owned by:
Priority: normal Milestone: 6.8.1
Component: Build System Version: 6.4.2
Keywords: Cc:
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by simonpj)

When building GHC on Windows, hsc2hs sometimes fails with

hsc2hs.exe: System\CPUTime_hsc_make.exe: removeFile: permission denied (Permission denied)

This is because it tries to remove a file it has open handle to. The error usually repeats per-machine and file, but what file and machine it shows up with, is random.

As a workaround, calls to removeFile can be removed, or exceptions catched.

From a mail by Brian Smith:

Change History (6)

comment:1 Changed 11 years ago by simonpj

Sigbjorn writes: This is a long standing, irksome Win32 timing issue, and is not GC related (AFAICR, it was reproducible in straight C code).

A better workaround, which was experimented with in STABLE at some point, is to simply delay the clean up of the files until the end of hsc2hs's run

comment:2 Changed 11 years ago by simonpj

Brian Smith adds: hsc2hs generates an EXE file, then executes it, then waits for that process to finish, and then attempts to delete the file. The file is never opened by hsc2hs directly so the GC does not seem to be the cause.

It seems that even though waitForProcess returns successfully, Windows still an open file handle for the EXE file when removeFile is called. That is really surprising because I expect that the file should be free to delete after waitForProcess has returned.

I tried to rewrite the code so that it enters a remove-catch "permission denied"-sleep loop but I could not find a portable "sleep" IO action. For now, I just commented out the entire removeFile action.

comment:3 Changed 11 years ago by simonpj

Description: modified (diff)

comment:4 Changed 11 years ago by simonpj

Component: CompilerBuild System
Milestone: 6.8
Resolution: fixed
Status: newclosed

Sigbjorn seems to have fixed this on Sept 9th:

Sat Sep 9 15:44:32 GMT Standard Time 2006 sof@…

  • remove generated files in a 'finally' manner

M ./utils/hsc2hs/Main.hs -4 +17

It looks as if the fix emits a message saying that it failed to remove a file, but it won't fall over.

comment:5 Changed 10 years ago by igloo

Milestone: 6.8 branch6.8.1

comment:6 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple
Note: See TracTickets for help on using tickets.