[GHC] #10320: -ddump-to-file should create empty dump files when there was nothing to dump

GHC ghc-devs at haskell.org
Thu Dec 3 09:35:01 UTC 2015


#10320: -ddump-to-file should create empty dump files when there was nothing to
dump
-------------------------------------+-------------------------------------
        Reporter:  rwbarton          |                Owner:  tvv
            Type:  bug               |               Status:  patch
        Priority:  low               |            Milestone:
       Component:  Compiler          |              Version:  7.10.1
      Resolution:                    |             Keywords:  newcomer
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D1514
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by tvv):

 It happens because I forgot to clear map in `closeDumpFiles`. And yes,
 looks like I picked the wrong place to close handles.

 This patch should help to avoid the error:
 {{{
 diff --git a/compiler/main/ErrUtils.hs b/compiler/main/ErrUtils.hs
 index 5e585da..2d29452 100644
 --- a/compiler/main/ErrUtils.hs
 +++ b/compiler/main/ErrUtils.hs
 @@ -333,8 +333,11 @@ openDumpFiles dflags
  --
  closeDumpFiles :: DynFlags -> IO ()
  closeDumpFiles dflags
 -  = do gd <- readIORef $ generatedDumps dflags
 +  = do
 +       let gdref = generatedDumps dflags
 +       gd <- readIORef gdref
         mapM_ hClose $ Map.elems gd
 +       writeIORef gdref Map.empty

  -- | Write out a dump.
  -- If --dump-to-file is set then this goes to a file.
 }}}
 but the compiler will produce incomplete dumps in some cases.

 Let me check it again and I will re-submit the patch.

 Thank you.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10320#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list