Opened 15 years ago

Closed 15 years ago

Last modified 7 months ago

#1 closed bug (Fixed)

Implicit parameters cause strange behavi

Reported by: nobody Owned by: nobody
Priority: normal Milestone:
Component: Compiler Version: 5.0
Keywords: Cc:
Operating System: Architecture:
Type of failure: Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

ghc-5.00.1 (with glasgow-exts) compiles the following
program:

> foo :: ((?x :: Int) => b) -> Int -> b
> foo s z = s with ?x = z
> main = foo (print ?x) 42

Running the generated code prints nothing. (No output
is produced
even if we add putStr "Hello world\n" before the call
to foo).

Change History (2)

comment:1 Changed 15 years ago by simonpj

  • Status changed from assigned to closed
Logged In: YES 
user_id=50165

Works fine with GHC 5.02 (about to be released)

comment:2 Changed 7 months ago by Sergei Trofimovich <siarheit@…>

In ade1a461/ghc:

Fix minimum alignment for StgClosure (Trac #11395)

The bug is observed on m68k-linux target as crash
in RTS:

    -- a.hs:
    main = print 43

    $ inplace/bin/ghc-stage1 --make -debug a.hs

    $ ./a
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0  0x80463b0a in LOOKS_LIKE_INFO_PTR_NOT_NULL (p=32858)
        at includes/rts/storage/ClosureMacros.h:248
    (gdb) bt
    #0  0x80463b0a in LOOKS_LIKE_INFO_PTR_NOT_NULL (p=32858)
        at includes/rts/storage/ClosureMacros.h:248
    #1  0x80463b46 in LOOKS_LIKE_INFO_PTR (p=32858)
        at includes/rts/storage/ClosureMacros.h:253
    #2  0x80463b6c in LOOKS_LIKE_CLOSURE_PTR (
            p=0x805aac6e <stg_dummy_ret_closure>)
        at includes/rts/storage/ClosureMacros.h:258
    #3  0x80463e4c in initStorage ()
        at rts/sm/Storage.c:121
    #4  0x8043ffb4 in hs_init_ghc (...)
        at rts/RtsStartup.c:181
    #5  0x80455982 in hs_main (...)
        at rts/RtsMain.c:51
    #6  0x80003c1c in main ()

GHC assumes last 2 pointer bits are tags on 32-bit targets.
But here 'stg_dummy_ret_closure' address violates the assumption:

    LOOKS_LIKE_CLOSURE_PTR (p=0x805aac6e <stg_dummy_ret_closure>)

I've added compiler hint for static StgClosure objects to
align closures at least by their natural alignment (what GHC assumes).
See Note [StgWord alignment].

Signed-off-by: Sergei Trofimovich <siarheit@google.com>

Test Plan: ran basic test on m68k qemu, it got past ASSERTs

Reviewers: simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #11395
Note: See TracTickets for help on using tickets.