Opened 15 years ago

Closed 15 years ago

Last modified 7 months ago

#3 closed bug (Fixed)

DiffArray should be instance of Show

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

Description

I would think that DiffArray should be an instance of
Show.  It's not.

   thanks,
   mike

Change History (3)

comment:1 Changed 15 years ago by simonmar

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

I've added Show instances for DiffArray and DiffUArray.

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

In 74897dec/ghc:

Make rts/ThreadLabels.c threadsafe for debug runtime.

rts/ThreadLabels.c has a global hashtable for each
running haskell thread. It's not synchronized across
OS threads.

Was discovered when ran -debug build of ghc itself as:

    $ ghc-stage2 -j8 +RTS -A256M -l

and glibc detected double-free corruption:

    #2  in __libc_message (do_abort=do_abort@entry=2,
        fmt=fmt@entry=0x7fe0bcebf368 "*** Error in `%s': %s: 0x%s ***\n")
    #3  in malloc_printerr (action=3, str=0x7fe0bcebf4c0 "double free or corruption (fasttop)",
        ptr=<optimized out>)
    #4  in _int_free (av=<optimized out>, p=<optimized out>, have_lock=0)
    #5  in stgFree (p=0x7fe060001820) at rts/RtsUtils.c:108
    #6  in freeHashTable (table=0x5929320, freeDataFun=0x36374df <stgFree>) at rts/Hash.c:360
    #7  in freeThreadLabelTable () at rts/ThreadLabels.c:37
    #8  in hs_exit_ (wait_foreign=rtsFalse) at rts/RtsStartup.c:403
    #9  in shutdownHaskellAndExit (n=0, fastExit=0) at rts/RtsStartup.c:481
    #10 in hs_main (...) at rts/RtsMain.c:91
    #11 in main (...) at ghc/hschooks.c:63

Exposed itself after commit:

> commit f6866824ce5cdf5359f0cad78c49d65f6d43af12
> Author: Sergei Trofimovich <slyfox@gentoo.org>
> Date:   Mon Aug 4 08:10:33 2014 -0500
>
>     ghc --make: add nicer names to RTS threads (threaded IO manager, make workers)

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

Reviewers: austin, simonmar, ezyang, bgamari

Reviewed By: ezyang, bgamari

Subscribers: thomie

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

comment:3 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.