Opened 5 years ago

Last modified 18 months ago

#9775 upstream bug

"Failed to remove" errors during Windows build from hsc2hs

Reported by: gintas Owned by:
Priority: normal Milestone: 8.8.1
Component: hsc2hs Version: 7.8.3
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 gintas)

The Windows build over here spews a bunch of errors during the build like the ones below. All of them seem to be related to hsc2hs. The errors do not break the build for some reason, so the problem is not critical, but we should look into what's going on here.

Note that the errors are indeterministic and the set of files affected varies between builds.

Examples:

ghctrace.2/3.log:Failed to remove file libraries/base/dist-install/build/System/CPUTime_hsc_make.exe; error= DeleteFile "libraries/base/dist-install/build/System/CPUTime_hsc_make.exe": permission denied (Access is denied.)
ghctrace.2/4.log:Failed to remove file libraries/hpc/dist-boot/build/Trace/Hpc/Reflect_hsc_make.exe; error= DeleteFile "libraries/hpc/dist-boot/build/Trace/Hpc/Reflect_hsc_make.exe": permission denied (Access is denied.)
ghctrace.2/4.log:Failed to remove file compiler/stage2/build/Fingerprint_hsc_make.exe; error= DeleteFile "compiler/stage2/build/Fingerprint_hsc_make.exe": permission denied (Access is denied.)
ghctrace.3/1.log:Failed to remove file libraries/hpc/dist-boot/build/Trace/Hpc/Reflect_hsc_make.exe; error= DeleteFile "libraries/hpc/dist-boot/build/Trace/Hpc/Reflect_hsc_make.exe": permission denied (Access is denied.)
ghctrace.3/4.log:Failed to remove file libraries/old-time/dist-install/build/System/Time_hsc_make.exe; error= DeleteFile "libraries/old-time/dist-install/build/System/Time_hsc_make.exe": permission denied (Access is denied.)
ghctrace.3/5.log:Failed to remove file libraries/Win32/dist-install/build/Graphics/Win32/GDI/Pen_hsc_make.exe; error= DeleteFile "libraries/Win32/dist-install/build/Graphics/Win32/GDI/Pen_hsc_make.exe": permission denied (Access is denied.)

Change History (17)

comment:1 Changed 5 years ago by gintas

Description: modified (diff)

comment:2 Changed 5 years ago by gintas

Looks like this is an old issue, all the way back from 2006, see here:

http://web.archiveorange.com/archive/v/j7U5ds4Ozu7dvDiQLdtl

The code that spews the error is already trying to work around the issue, but fails, it just does not break the build process. On the bright side, this particular error is not harmful, the outcome is just that a temporary file does not get deleted.

Relevant code:

-- delay the cleanup of generated files until the end; attempts to
-- get around intermittent failure to delete files which has
-- just been exec'ed by a sub-process (Win32 only.)
finallyRemove :: FilePath -> IO a -> IO a
finallyRemove fp act =
  bracket_ (return fp)
           (const $ noisyRemove fp)
           act
 where
  noisyRemove fpath =
    catch (removeFile fpath)
          (\ e -> hPutStrLn stderr ("Failed to remove file " ++ fpath ++ "; error= " ++ show e))

comment:3 Changed 5 years ago by gintas

Priority: normallow

comment:4 Changed 5 years ago by thomie

Component: Build Systemhsc2hs

comment:5 Changed 3 years ago by Phyx-

Milestone: 8.2.1
Owner: set to Phyx-
Priority: lownormal

This is blocking reliable clean validates. Think I have a fix for it.

comment:6 Changed 3 years ago by bgamari

Phyx, did this ever get fixed?

comment:7 Changed 3 years ago by Phyx-

I implemented the required changed in process but ran into some issues that I'm still working on.

https://github.com/haskell/process/issues/77

I should have it done this week.

comment:8 Changed 3 years ago by Phyx-

Pull request submitted to Process[1] Now to update hsc2hs.

[1] https://github.com/haskell/process/pull/80

comment:9 Changed 3 years ago by Tamar Christina <tamar@…>

In a3704409/ghc:

Fix various issues with testsuite code on Windows

Summary:
Previously we would make direct calls to `diff` using `os.system`.
On Windows `os.system` is implemented using the standard
idiom `CreateProcess .. WaitForSingleObject ..`.

This again runs afoul with the `_exec` behaviour on Windows. So we ran
into some trouble where sometimes `diff` would return before it's done.

On tests which run multiple ways, such as `8086` what happens is that
we think the diff is done and continue. The next way tries to set things
up again by removing any previous directory. This would then fail with
and error saying the directory can't be removed. Which is true, because
the previous diff code/child is still running.

We shouldn't make any external calls to anything using `os.system`.
Instead just use `runCmd` which uses `timeout`. This also ensures that if
we hit the cygwin bug where diff or any other utility hangs, we kill it and
continue and not hang the entire test and leave hanging processes.

Further more we also:
Ignore error lines from `removeFile` from tools in the testsuite. This is a rather large
hammer to work around the fact that `hsc2hs` often tries to remove it's own file too early.
When this is patched the workaround can be removed. See Trac #9775

We mark `prog003` as skip. Since this test randomly fails and passes. For stability it's disabled
but it is a genuine bug which we should find. It's something with interface files being
overwritten. See Trac #11317

when `rmtree` hits a readonly file, the `onerror` handler is raised afterwards but not
during the tree walk. It doesn't allow you to recover and continue as we thought.
Instead you have to explicitly start again. This is why sometimes even though we
call `cleanup` before `os.mkdirs`, it would sometimes fail with an error that the
folder already exists. So we now do a second walk.

A new verbosity level (4) will strip the silent flags from `MAKE` invocations so you can actually
see what's going on.

Test Plan: ./validate on build bots.

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: mpickering, thomie, #ghc_windows_task_force

Differential Revision: https://phabricator.haskell.org/D2894

GHC Trac Issues: #12661, #11317, #9775

comment:10 Changed 3 years ago by bgamari

Priority: normalhigh
Status: newupstream

This is waiting on a the process PR mentioned in comment:7. Bumping in priority since I would really like to have Windows finally stable.

comment:11 Changed 3 years ago by Phyx-

I currently have a new version of the pull request, just need to finish testing.

I also committed a workaround for this in the testsuite. The error seems to not change the exit code as it seems to be mostly informational. Also the work seems to be done it's just cleaning up that fails. So I had the testsuite just strip this message out if it's found.

The test runs shouldn't be reporting this anymore.

comment:12 Changed 3 years ago by Phyx-

Priority: highnormal

The testsuite deals with this error internally now by removing it from the output. It is no longer a blocker.

comment:13 Changed 3 years ago by bgamari

Milestone: 8.2.18.2.2

Then perhaps we can just bump further work off to 8.2.2 at the earliest.

comment:14 Changed 2 years ago by bgamari

Milestone: 8.2.28.4.1

Bumping off to 8.4.

comment:15 Changed 2 years ago by Phyx-

Owner: Phyx- deleted

comment:16 Changed 23 months ago by bgamari

Milestone: 8.4.18.6.1

This ticket won't be resolved in 8.4; remilestoning for 8.6. Do holler if you are affected by this or would otherwise like to work on it.

comment:17 Changed 18 months ago by bgamari

Milestone: 8.6.18.8.1

These won't be fixed for 8.6, bumping to 8.8.

Note: See TracTickets for help on using tickets.