Opened 2 years ago

Closed 23 months ago

Last modified 22 months ago

#7878 closed bug (fixed)

Panic when using DerivingGeneric with hs-boot

Reported by: ryant5000 Owned by: dreixel
Priority: normal Milestone:
Component: Compiler Version: 7.7
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Compile-time crash Test Case: generics/T7878
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description (last modified by simonpj)

When a module that uses DerivingGeneric has an hs-boot file, a panic like the following results:

ghc: panic! (the 'impossible' happened)
  (GHC version 7.6.3 for x86_64-unknown-linux):
	tcIfaceGlobal (local): not found:
    main:A.D1Test{tc apn}
    [(roo,ghc: panic! (the 'impossible' happened)
  (GHC version 7.6.3 for x86_64-unknown-linux):
	ghc: panic! (the 'impossible' happened)
  (GHC version 7.6.3 for x86_64-unknown-linux):
	tcIfaceGlobal (local): not found:

The attached files demonstrate the issue. To reproduce, run ghc --make C. Note that running the same command a second time will not cause the error, unless *.hi* files are deleted.

Attachments (5)

A.hs (104 bytes) - added by ryant5000 2 years ago.
B.hs (40 bytes) - added by ryant5000 2 years ago.
C.hs (25 bytes) - added by ryant5000 2 years ago.
A.hs-boot (90 bytes) - added by ryant5000 2 years ago.
0001-Update-the-name-cache-when-creating-new-names-via-De.patch (3.1 KB) - added by parcs 23 months ago.

Download all attachments as: .zip

Change History (14)

Changed 2 years ago by ryant5000

Changed 2 years ago by ryant5000

Changed 2 years ago by ryant5000

Changed 2 years ago by ryant5000

comment:1 Changed 2 years ago by ryant5000

It appears that using DerivingGeneric in other files in the cycle, even if they don't themselves use hs-boot files, also sometimes causes this problem, but not always.

comment:2 Changed 2 years ago by dreixel

  • Owner set to dreixel
  • Version changed from 7.6.3 to 7.7

Confirmed with HEAD. Thanks for reporting; I'll take a look.

comment:3 Changed 2 years ago by simonpj

  • Description modified (diff)
  • difficulty set to Unknown

comment:4 Changed 23 months ago by parcs

  • Status changed from new to patch

I think I have a solution (attached): genGenericMetaTyCons creates new top-level external names but it doesn't populate the name cache with them. Creating the names with newGlobalBinder, which in turn updates the name cache, fixes this issue (and still passes the testsuite). Though I don't know whether this is the correct solution.

comment:5 Changed 23 months ago by simonpj

Yes, I think that's the right solution.

See the documentation of External names in Commentary/Compiler/NameType. I'll add a note with IfaceEnv.newGlobalBinder.

Simon

comment:6 Changed 23 months ago by patrick@…

commit ad1bc9dcc67d7c0d51fa2c71e8188c79ce3ebb1e

Author: Patrick Palka <[email protected]>
Date:   Sun May 5 22:41:27 2013 -0400

    Update the name cache when creating new names via DeriveGeneric
    
    New external top-level names were being created but the name cache
    wasn't being populated, leading to #7878.
    
    Signed-off-by: Jose Pedro Magalhaes <[email protected]>

 compiler/typecheck/TcGenGenerics.lhs |   32 +++++++++++---------------------
 1 files changed, 11 insertions(+), 21 deletions(-)

comment:7 Changed 23 months ago by dreixel

  • Resolution set to fixed
  • Status changed from patch to closed

Thanks; patch applied, testcase T7878 added.

comment:8 Changed 22 months ago by ryant5000

Thanks! I've verified that this patch fixes the issue in several more complex test cases as well.

comment:9 Changed 22 months ago by simonpj

  • Test Case set to generics/T7878
Note: See TracTickets for help on using tickets.