Ticket #5527 (closed bug: fixed)

Opened 20 months ago

Last modified 12 months ago

mkTopLevEnv: not interpreted

Reported by: cdsmith Owned by: pcapriotti
Priority: normal Milestone: 7.6.1
Component: GHC API Version: 7.3
Keywords: Cc:
Operating System: Linux Architecture: x86
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

When attempting to compile, load, and use a module several times per second with the GHC API, the compiler sometimes reports an error "mkTopLevEnv: not interpreted" for the module being loaded, even when that module isn't supposed to be interpreted.

The attached file exhibits the bug when runs multiple times in quick succession (less than a second apart). The important ingredients are:

1. The same file is being compiled each time. 2. The .hi and .o files still exist from the previous compile. 3. The compiles are happening less than a second apart.

There's some suspicion that this is a problem with timestamp resolution.

This happens at least as far back as 7.1, and has been confirmed in the latest i386-linux development snapshot (7.3, from Sep 6, 2011). The attached code is for 7.3, but analogous code for older versions shows the same bug.

Attachments

Test.hs Download (0.9 KB) - added by cdsmith 20 months ago.
Test case
5527.patch Download (4.0 KB) - added by pcapriotti 12 months ago.

Change History

Changed 20 months ago by cdsmith

Test case

Changed 20 months ago by cdsmith

  • os changed from Unknown/Multiple to Linux
  • architecture changed from Unknown/Multiple to x86

Changed 20 months ago by simonpj

See this thread for more details:  http://www.haskell.org/pipermail/glasgow-haskell-users/2011-October/020975.html, including various situations in which the bug does or does not manifest itself.

Changed 20 months ago by simonmar

Plan:

  • In this particular use case, it is better use use "*A.hs" instead of "A.hs" for the target, as this tells GHC that you want the module to be interpreted so that you can have its entire top-level scope available for interactive evaluation.
  • We should make GHC.setContext emit a proper exception in this case, instead of the cryptic mkTopLevEnv error.
  • There are strange things afoot with -fobject-code too: #5534

Changed 20 months ago by simonmar

One more thing: there's a comment about the behaviour when the timestamps of the .o and .hs file match, in [source:compiler/main/GhcMake.hs] in the function checkStability. I'll add a pointer to this ticket from the comment.

Changed 19 months ago by igloo

  • milestone set to 7.6.1

Changed 13 months ago by pcapriotti

  • owner set to pcapriotti
  • difficulty set to Unknown

Changed 12 months ago by pcapriotti

Changed 12 months ago by pcapriotti

  • status changed from new to patch

If I understand correctly, the actual error here is in user code (setContext should be called with an IIDecl instead of an IIModule), and the timestamp-related issue is gone (the example now fails consistently).

The only remaining problem is the cryptic error message, which should be improved by the attached patch.

Changed 12 months ago by simonmar

pcapriotti: your patch looks ok to me, go ahead.

Changed 12 months ago by p.capriotti@…

commit b8e0074794e085fdc2271f39aec92a0b472c6b46

Author: Paolo Capriotti <p.capriotti@gmail.com>
Date:   Wed Jun 6 15:24:21 2012 +0100

    Better error messages for setContext (#5527).
    
    Make InteractiveEval.setContext throw a clearer exception when it is
    asked to add an IIModule which is not a home module or is not
    interpreted.

 compiler/main/InteractiveEval.hs |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

Changed 12 months ago by pcapriotti

  • status changed from patch to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.