Skip to content
  • Sergei Trofimovich's avatar
    Make rts/ThreadLabels.c threadsafe for debug runtime. · 74897dec
    Sergei Trofimovich authored
    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...
    74897dec