1. 20 May, 2018 1 commit
    • Ömer Sinan Ağacan's avatar
      Fix #15038 · 64ecfc37
      Ömer Sinan Ağacan authored
      We introduce a new Id for unused pointer values in unboxed sums that is
      not CAFFY. Because the Id is not CAFFY it doesn't make non-CAFFY
      definitions CAFFY, fixing #15038.
      
      To make sure anything referenced by the new id will be retained we get a
      stable pointer to in on RTS startup.
      
      Test Plan: Passes validate
      
      Reviewers: simonmar, simonpj, hvr, bgamari, erikd
      
      Reviewed By: simonmar
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #15038
      
      Differential Revision: https://phabricator.haskell.org/D4680
      
      (cherry picked from commit b2ff5dde)
      64ecfc37
  2. 02 Nov, 2017 1 commit
    • David Feuer's avatar
      Add custom exception for fixIO · b938576d
      David Feuer authored
      Traditionally, `fixIO f` throws `BlockedIndefinitelyOnMVar` if
      `f` is strict. This is not particularly friendly, since the
      `MVar` in question is just part of the way `fixIO` happens to be
      implemented. Instead, throw a new `FixIOException` with a better
      explanation of the problem.
      
      Reviewers: austin, hvr, bgamari
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #14356
      
      Differential Revision: https://phabricator.haskell.org/D4113
      b938576d
  3. 01 Mar, 2017 1 commit
    • David Feuer's avatar
      Change catch# demand signature · 701256df
      David Feuer authored
      * Give `catch#` a lazy demand signature, to make it more honest.
      
      * Make `catchException` and `catchAny` force their arguments so they
      actually behave as advertised.
      
      * Use `catch` rather than `catchException` in `forkIO`, `forkOn`, and
      `forkOS` to avoid losing exceptions.
      
      Fixes #13330
      
      Reviewers: rwbarton, simonpj, simonmar, bgamari, hvr, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3244
      701256df
  4. 07 Dec, 2016 1 commit
    • Simon Marlow's avatar
      Overhaul of Compact Regions (#12455) · 7036fde9
      Simon Marlow authored
      Summary:
      This commit makes various improvements and addresses some issues with
      Compact Regions (aka Compact Normal Forms).
      
      This was the most important thing I wanted to fix.  Compaction
      previously prevented GC from running until it was complete, which
      would be a problem in a multicore setting.  Now, we compact using a
      hand-written Cmm routine that can be interrupted at any point.  When a
      GC is triggered during a sharing-enabled compaction, the GC has to
      traverse and update the hash table, so this hash table is now stored
      in the StgCompactNFData object.
      
      Previously, compaction consisted of a deepseq using the NFData class,
      followed by a traversal in C code to copy the data.  This is now done
      in a single pass with hand-written Cmm (see rts/Compact.cmm). We no
      longer use the NFData instances, instead the Cmm routine evaluates
      components directly as it compacts.
      
      The new compaction is about 50% faster than the old one with no
      sharing, and a little faster on average with sharing (the cost of the
      hash table dominates when we're doing sharing).
      
      Static objects that don't (transitively) refer to any CAFs don't need
      to be copied into the compact region.  In particular this means we
      often avoid copying Char values and small Int values, because these
      are static closures in the runtime.
      
      Each Compact# object can support a single compactAdd# operation at any
      given time, so the Data.Compact library now enforces mutual exclusion
      using an MVar stored in the Compact object.
      
      We now get exceptions rather than killing everything with a barf()
      when we encounter an object that cannot be compacted (a function, or a
      mutable object).  We now also detect pinned objects, which can't be
      compacted either.
      
      The Data.Compact API has been refactored and cleaned up.  A new
      compactSize operation returns the size (in bytes) of the compact
      object.
      
      Most of the documentation is in the Haddock docs for the compact
      library, which I've expanded and improved here.
      
      Various comments in the code have been improved, especially the main
      Note [Compact Normal Forms] in rts/sm/CNF.c.
      
      I've added a few tests, and expanded a few of the tests that were
      there.  We now also run the tests with GHCi, and in a new test way
      that enables sanity checking (+RTS -DS).
      
      There's a benchmark in libraries/compact/tests/compact_bench.hs for
      measuring compaction speed and comparing sharing vs. no sharing.
      
      The field totalDataW in StgCompactNFData was unnecessary.
      
      Test Plan:
      * new unit tests
      * validate
      * tested manually that we can compact Data.Aeson data
      
      Reviewers: gcampax, bgamari, ezyang, austin, niteria, hvr, erikd
      
      Subscribers: thomie, simonpj
      
      Differential Revision: https://phabricator.haskell.org/D2751
      
      GHC Trac Issues: #12455
      7036fde9
  5. 06 Jun, 2016 1 commit
  6. 11 Mar, 2016 1 commit
    • Ben Gamari's avatar
      Make `catch` lazy in the action · 30ee9102
      Ben Gamari authored
      Previously
      ```lang=haskell
      catch (error "uh oh") (\(_ :: SomeException) -> print "it failed")
      ```
      would unexpectedly fail with "uh oh" instead of the handler being run
      due to the strictness of `catch` in its first argument. See #11555 for
      details.
      
      Test Plan: Validate
      
      Reviewers: austin, hvr, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1973
      
      GHC Trac Issues: #11555
      30ee9102
  7. 02 Feb, 2016 1 commit
    • Ryan Scott's avatar
      Make TypeError a newtype, add changelog entry · a7ad0b91
      Ryan Scott authored
      Summary:
      Phab:D866 added the `TypeError` datatype to `Control.Exception` to represent
      the error that is thrown when `-fdefer-type-errors` is on, but a changelog
      entry for it was never added. In addition, it should probably be a
      newtype.
      
      Reviewers: austin, hvr, KaneTW, bgamari
      
      Reviewed By: KaneTW, bgamari
      
      Subscribers: thomie, KaneTW
      
      Differential Revision: https://phabricator.haskell.org/D1873
      
      GHC Trac Issues: #10284
      a7ad0b91
  8. 23 Dec, 2015 1 commit
    • Eric Seidel's avatar
      Allow CallStacks to be frozen · 380b25ea
      Eric Seidel authored
      This introduces "freezing," an operation which prevents further
      locations from being appended to a CallStack.  Library authors may want
      to prevent CallStacks from exposing implementation details, as a matter
      of hygiene. For example, in
      
      ```
      head [] = error "head: empty list"
      
      ghci> head []
      *** Exception: head: empty list
      CallStack (from implicit params):
        error, called at ...
      ```
      
      including the call-site of `error` in `head` is not strictly necessary
      as the error message already specifies clearly where the error came
      from.
      
      So we add a function `freezeCallStack` that wraps an existing CallStack,
      preventing further call-sites from being pushed onto it. In other words,
      
      ```
      pushCallStack callSite (freezeCallStack callStack) = freezeCallStack callStack
      ```
      
      Now we can define `head` to not produce a CallStack at all
      
      ```
      head [] =
        let ?callStack = freezeCallStack emptyCallStack
        in error "head: empty list"
      
      ghci> head []
      *** Exception: head: empty list
      CallStack (from implicit params):
        error, called at ...
      ```
      
      ---
      
      1. We add the `freezeCallStack` and `emptyCallStack` and update the
         definition of `CallStack` to support this functionality.
      
      2. We add `errorWithoutStackTrace`, a variant of `error` that does not
         produce a stack trace, using this feature. I think this is a sensible
         wrapper function to provide in case users want it.
      
      3. We replace uses of `error` in base with `errorWithoutStackTrace`. The
         rationale is that base does not export any functions that use CallStacks
         (except for `error` and `undefined`) so there's no way for the stack
         traces (from Implicit CallStacks) to include user-defined functions.
         They'll only contain the call to `error` itself. As base already has a
         good habit of providing useful error messages that name the triggering
         function, the stack trace really just adds noise to the error. (I don't
         have a strong opinion on whether we should include this third commit,
         but the change was very mechanical so I thought I'd include it anyway in
         case there's interest)
      
      4. Updates tests in `array` and `stm` submodules
      
      Test Plan: ./validate, new test is T11049
      
      Reviewers: simonpj, nomeata, goldfire, austin, hvr, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: thomie
      
      Projects: #ghc
      
      Differential Revision: https://phabricator.haskell.org/D1628
      
      GHC Trac Issues: #11049
      380b25ea
  9. 08 Dec, 2015 1 commit
  10. 02 Sep, 2015 1 commit
    • Eric Seidel's avatar
      Use IP based CallStack in error and undefined · 6740d70d
      Eric Seidel authored
      This patch modifies `error`, `undefined`, and `assertError` to use
      implicit call-stacks to provide better error messages to users.
      
      There are a few knock-on effects:
      
      - `GHC.Classes.IP` is now wired-in so it can be used in the wired-in
        types for `error` and `undefined`.
      
      - `TysPrim.tyVarList` has been replaced with a new function
        `TysPrim.mkTemplateTyVars`. `tyVarList` made it easy to introduce
        subtle bugs when you need tyvars of different kinds. The naive
      
        ```
        tv1 = head $ tyVarList kind1
        tv2 = head $ tyVarList kind2
        ```
      
        would result in `tv1` and `tv2` sharing a `Unique`, thus substitutions
        would be applied incorrectly, treating `tv1` and `tv2` as the same
        tyvar. `mkTemplateTyVars` avoids this pitfall by taking a list of kinds
        and producing a single tyvar of each kind.
      
      - The types `GHC.SrcLoc.SrcLoc` and `GHC.Stack.CallStack` now live in
        ghc-prim.
      
      - The type `GHC.Exception.ErrorCall` has a new constructor
        `ErrorCallWithLocation` that takes two `String`s instead of one, the
        2nd one being arbitrary metadata about the error (but usually the
        call-stack). A bi-directional pattern synonym `ErrorCall` continues to
        provide the old API.
      
      Updates Cabal, array, and haddock submodules.
      
      Reviewers: nh2, goldfire, simonpj, hvr, rwbarton, austin, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, rodlogic, goldfire, maoe, simonmar, carter,
      liyang, bgamari, thomie
      
      Differential Revision: https://phabricator.haskell.org/D861
      
      GHC Trac Issues: #5273
      6740d70d
  11. 05 Aug, 2015 1 commit
  12. 07 Jul, 2015 1 commit
  13. 07 Mar, 2015 1 commit
  14. 12 Nov, 2014 1 commit
  15. 24 Sep, 2014 1 commit
  16. 16 Sep, 2014 1 commit
  17. 27 May, 2014 1 commit
    • Herbert Valerio Riedel's avatar
      Replace DeriveDataTypeable by AutoDeriveTypeable · 6ed54303
      Herbert Valerio Riedel authored
      This is a first step towards addressing #9111
      
      This results in the following additional Typeable (exported) instances
      being generated (list was compiled by diff'ing hoogle txt output):
      
        instance Typeable CFile
        instance Typeable 'CFile
        instance Typeable CFpos
        instance Typeable 'CFpos
        instance Typeable CJmpBuf
        instance Typeable 'CJmpBuf
        instance Typeable ChItem
        instance Typeable QSem
        instance Typeable ID
        instance Typeable 'ID
        instance Typeable CONST
        instance Typeable Qi
        instance Typeable Qr
        instance Typeable Mp
        instance Typeable ConstrRep
        instance Typeable Fixity
        instance Typeable 'Prefix
        instance Typeable 'Infix
        instance Typeable Constr
        instance Typeable DataType
        instance Typeable DataRep
        instance Typeable Data
        instance Typeable HasResolution
        instance Typeable IsList
      Signed-off-by: Herbert Valerio Riedel's avatarHerbert Valerio Riedel <hvr@gnu.org>
      6ed54303
  18. 04 May, 2014 1 commit
  19. 02 May, 2014 1 commit
    • Simon Marlow's avatar
      Per-thread allocation counters and limits · b0534f78
      Simon Marlow authored
      This tracks the amount of memory allocation by each thread in a
      counter stored in the TSO.  Optionally, when the counter drops below
      zero (it counts down), the thread can be sent an asynchronous
      exception: AllocationLimitExceeded.  When this happens, given a small
      additional limit so that it can handle the exception.  See
      documentation in GHC.Conc for more details.
      
      Allocation limits are similar to timeouts, but
      
        - timeouts use real time, not CPU time.  Allocation limits do not
          count anything while the thread is blocked or in foreign code.
      
        - timeouts don't re-trigger if the thread catches the exception,
          allocation limits do.
      
        - timeouts can catch non-allocating loops, if you use
          -fno-omit-yields.  This doesn't work for allocation limits.
      
      I couldn't measure any impact on benchmarks with these changes, even
      for nofib/smp.
      b0534f78
  20. 17 Sep, 2013 3 commits
  21. 19 Feb, 2013 2 commits
  22. 15 Feb, 2013 1 commit
  23. 10 Dec, 2012 1 commit
    • Simon Marlow's avatar
      Make a class for asynchronous exceptions in the exception hierarchy · 756a970e
      Simon Marlow authored
      Right now, we only have
      
      data AsyncException
        = StackOverflow
        | HeapOverflow
        | ThreadKilled
        | ...
      
      so it is not possible to add another async exception.  For instance,
      the Timeout exception in System.Timeout should really be an async
      exception.
      
      This patch adds a superclass for all async exceptions:
      
      data SomeAsyncException = forall e . Exception e => SomeAsyncException e
        deriving Typeable
      
      and makes the existing AsyncException and Timeout children of
      SomeAsyncException in the hierarchy.
      756a970e
  24. 17 Nov, 2012 1 commit
  25. 19 Oct, 2012 1 commit
  26. 18 Oct, 2011 1 commit
  27. 18 Jun, 2011 1 commit
  28. 14 May, 2011 1 commit
    • batterseapower's avatar
      Big patch to improve Unicode support in GHC. Validated on OS X and Windows, this · dc58b739
      batterseapower authored
      patch series fixes #5061, #1414, #3309, #3308, #3307, #4006 and #4855.
      
      The major changes are:
      
       1) Make Foreign.C.String.*CString use the locale encoding
      
          This change follows the FFI specification in Haskell 98, which
          has never actually been implemented before.
      
          The functions exported from Foreign.C.String are partially-applied
          versions of those from GHC.Foreign, which allows the user to supply
          their own TextEncoding.
      
          We also introduce foreignEncoding as the name of the text encoding
          that follows the FFI appendix in that it transliterates encoding
          errors.
      
       2) I also changed the code so that mkTextEncoding always tries the
          native-Haskell decoders in preference to those from iconv, even on
          non-Windows. The motivation here is simply that it is better for
          compatibility if we do this, and those are the ones you get for
          the utf* and latin1* predefined TextEncodings anyway.
      
       3) Implement surrogate-byte error handling mode for TextEncoding
      
          This implements PEP383-like behaviour so that we are able to
          roundtrip byte strings through Strings without loss of information.
      
          The withFilePath function now uses this encoding to get to/from CStrings,
          so any code that uses that will get the right PEP383 behaviour automatically.
      
       4) Implement three other coding failure modes: ignore, throw error, transliterate
      
          These mimic the behaviour of the GNU Iconv extensions.
      dc58b739
  29. 24 Apr, 2011 1 commit
  30. 28 Jan, 2011 1 commit
  31. 24 Sep, 2010 1 commit
  32. 14 Sep, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Add absentError. · c3c5bee6
      simonpj@microsoft.com authored
      This patch accompanies the HEAD patch:
      
        Tue Sep 14 12:38:27 BST 2010  simonpj@microsoft.com
          * Make absent-arg wrappers work for unlifted types (fix Trac #4306)
          
          Previously we were simply passing arguments of unlifted
          type to a wrapper, even if they were absent, which was
          stupid.
          
          See Note [Absent error Id] in WwLib.
      c3c5bee6
  33. 10 Aug, 2010 1 commit
  34. 10 Jul, 2010 1 commit
  35. 08 Jul, 2010 1 commit
    • Simon Marlow's avatar
      New asynchronous exception control API (base parts) · 73157075
      Simon Marlow authored
        
      As discussed on the libraries/haskell-cafe mailing lists
        http://www.haskell.org/pipermail/libraries/2010-April/013420.html
      
      This is a replacement for block/unblock in the asychronous exceptions
      API to fix a problem whereby a function could unblock asynchronous
      exceptions even if called within a blocked context.
      
      The new terminology is "mask" rather than "block" (to avoid confusion
      due to overloaded meanings of the latter).
      
      The following is the new API; the old API is deprecated but still
      available for the time being.
      
      Control.Exception
      -----------------
      
      mask  :: ((forall a. IO a -> IO a) -> IO b) -> IO b
      mask_ :: IO a -> IO a
      
      uninterruptibleMask :: ((forall a. IO a -> IO a) -> IO b) -> IO b
      uninterruptibleMask_ :: IO a -> IO 
      
      getMaskingState :: IO MaskingState
      
      data MaskingState
        = Unmasked
        | MaskedInterruptible 
        | MaskedUninterruptible
      
      
      Control.Concurrent
      ------------------
      
      forkIOUnmasked :: IO () -> IO ThreadId
      73157075
  36. 12 Mar, 2010 1 commit
  37. 01 Mar, 2010 1 commit