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

#10320: -ddump-to-file should create empty dump files when there was nothing to dump -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.10.1 Keywords: newcomer | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- For example, I ran with -ddump-rule-firings -ddump-to-file when there were no rule firings. GHC should have created an empty foo.dump-rule-firings file. (Instead it left the existing foo.dump-rule-firings from a previous run intact, which could have been misleading if I didn't already know that the most recent run had no rule firings.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10320: -ddump-to-file should create empty dump files when there was nothing to dump -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: MarceColl Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by MarceColl): * owner: => MarceColl -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10320: -ddump-to-file should create empty dump files when there was nothing to dump -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: MarceColl Type: bug | Status: new 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 Revisions: -------------------------------------+------------------------------------- Comment (by thomie): MarceColl: any progress? Pleas unassign yourself if you don't plan to work on this anymore. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10320: -ddump-to-file should create empty dump files when there was nothing to dump -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new 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): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * owner: MarceColl => Comment: Or just delete the old `foo.dump-rule-firings` file? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10320: -ddump-to-file should create empty dump files when there was nothing to dump -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: tvv Type: bug | Status: new 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): Wiki Page: | -------------------------------------+------------------------------------- Changes (by tvv): * owner: => tvv Comment: I think it's better to keep one but truncate its size. At least it can show that flags were specified correctly and there's nothing to dump. Seems that `-ddump-rule-rewrites` should be handled too. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: | -------------------------------------+------------------------------------- Changes (by tvv): * status: new => patch * differential: => Phab:D1514 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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 Ben Gamari

#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 osa1): This patch breaks things; try `-ddump-to-file -ddump-simpl`, it's failing with: {{{ Main.dump-simpl: hPutStr: illegal operation (handle is closed) }}} I had to comment out `bracket_`s first argument that closes handles. It seems like it's closing handles too soon. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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

#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 osa1): I tried to add a test for this, unfortunately as far as I can see this only happens when GHC panics(CoreLint errors may also trigger this, but I couldn't try this yet). Does anyone know a good way to add a test for this? In the meantime, can we revert this patch until someone comes up with a proper solution that works even when GHC panics? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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): How about to switch back to Phab:D1514:5330? It fixes the ticket's issue and does not introduce any side-effects like described. We can leave the dump optimization task as feature request. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10320: -ddump-to-file should create empty dump files when there was nothing to dump -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: 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: | -------------------------------------+------------------------------------- Changes (by tvv): * owner: tvv => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10320: -ddump-to-file should create empty dump files when there was nothing to dump -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new 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: | -------------------------------------+------------------------------------- Changes (by tvv): * status: patch => new -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10320: -ddump-to-file should create empty dump files when there was nothing to
dump
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner:
Type: bug | Status: new
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 thomie):
commit c5597bb6da612e0578290c3bccdac089d6519e19
{{{
Author: Ben Gamari

#10320: -ddump-to-file should create empty dump files when there was nothing to dump -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new 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 thomie): Replying to [comment:10 tvv]:
How about to switch back to Phab:D1514 Diff 5330? It fixes the ticket's issue and does not introduce any side-effects like described.
`pipeLoop` could be throwing exceptions, and dump files should be closed when that happens (there could be ghc api users recovering from the exception). Maybe someone else can have a look? It can't be //that// hard to fix this issue properly? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10320: -ddump-to-file should create empty dump files when there was nothing to dump -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: kaiha Type: bug | Status: new 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: | -------------------------------------+------------------------------------- Changes (by kaiha): * owner: => kaiha -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10320: -ddump-to-file should create empty dump files when there was nothing to dump -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: kaiha 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:D2015 Wiki Page: | -------------------------------------+------------------------------------- Changes (by kaiha): * status: new => patch * differential: Phab:D1514 => Phab:D2015 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10320: -ddump-to-file should create empty dump files when there was nothing to
dump
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner: kaiha
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:D2015
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10320: -ddump-to-file should create empty dump files when there was nothing to dump -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: kaiha Type: bug | Status: merge Priority: low | Milestone: 8.0.1 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:D2015 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge * milestone: => 8.0.1 @@ -1,5 +1,5 @@ - For example, I ran with -ddump-rule-firings -ddump-to-file when there were - no rule firings. GHC should have created an empty foo.dump-rule-firings - file. (Instead it left the existing foo.dump-rule-firings from a previous - run intact, which could have been misleading if I didn't already know that - the most recent run had no rule firings.) + For example, I ran with `-ddump-rule-firings -ddump-to-file` when there + were no rule firings. GHC should have created an empty `foo.dump-rule- + firings` file. (Instead it left the existing `foo.dump-rule-firings` from + a previous run intact, which could have been misleading if I didn't + already know that the most recent run had no rule firings.) New description: For example, I ran with `-ddump-rule-firings -ddump-to-file` when there were no rule firings. GHC should have created an empty `foo.dump-rule- firings` file. (Instead it left the existing `foo.dump-rule-firings` from a previous run intact, which could have been misleading if I didn't already know that the most recent run had no rule firings.) -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10320: -ddump-to-file should create empty dump files when there was nothing to dump -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: kaiha Type: bug | Status: closed Priority: low | Milestone: 8.0.1 Component: Compiler | Version: 7.10.1 Resolution: fixed | 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:D2015 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.0` as 35351996f47bde97db696cd9a08439e00bfc2f00. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10320#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC