1. 17 Mar, 2020 1 commit
  2. 14 Feb, 2020 1 commit
    • Ben Gamari's avatar
      base: Always clamp reads/writes to 2GB in length · 97497bae
      Ben Gamari authored
      Previously we did this only on Darwin due to #17414. However, even on
      other platforms >2GB writes are on shaky ground. POSIX explicitly says
      that the result is implementation-specified and Linux will write at most
      0x7ffff000, even on 64-bit platforms. Moreover, getting the sign
      of the syscall result correct is tricky, as demonstrated by the fact
      that T17414 currently fails on FreeBSD.
      
      For simplicity we now just uniformly clamp to 0x7ffff000 on all
      platforms.
      97497bae
  3. 27 Jan, 2020 1 commit
  4. 25 Jan, 2020 1 commit
  5. 04 Jan, 2020 1 commit
  6. 24 Dec, 2019 2 commits
  7. 19 Dec, 2019 1 commit
    • Moritz Kiefer's avatar
      Avoid race condition in hDuplicateTo · fad866e0
      Moritz Kiefer authored
      In our codebase we have some code along the lines of
      
      ```
      newStdout <- hDuplicate stdout
      stderr `hDuplicateTo` stdout
      ```
      
      to avoid stray `putStrLn`s from corrupting a protocol (LSP) that is
      run over stdout.
      
      On CI we have seen a bunch of issues where `dup2` returned `EBUSY` so
      this fails with `ResourceExhausted` in Haskell.
      
      I’ve spent some time looking at the docs for `dup2` and the code in
      `base` and afaict the following race condition is being triggered
      here:
      
      1. The user calls `hDuplicateTo stderr stdout`.
      2. `hDuplicateTo` calls `hClose_help stdout_`, this closes the file
      handle for stdout.
      3. The file handle for stdout is now free, so another thread
      allocating a file might get stdout.
      4. If `dup2` is called while `stdout` (now pointing to something
      else) is half-open, it returns EBUSY.
      
      I think there might actually be an even worse case where `dup2` is run
      after FD 1 is fully open again. In that case, you will end up not just
      redirecting the original stdout to stderr but also the whatever
      resulted in that file handle being allocated.
      
      As far as I can tell, `dup2` takes care of closing the file handle
      itself so there is no reason to do this in `hDuplicateTo`. So this PR
      replaces the call to `hClose_help` by the only part of `hClose_help`
      that we actually care about, namely, `flushWriteBuffer`.
      
      I tested this on our codebase fairly extensively and haven’t been able
      to reproduce the issue with this patch.
      fad866e0
  8. 02 Dec, 2019 1 commit
  9. 08 Nov, 2019 1 commit
  10. 31 Oct, 2019 1 commit
  11. 29 Oct, 2019 2 commits
  12. 23 Oct, 2019 1 commit
  13. 29 May, 2019 1 commit
  14. 15 Feb, 2019 1 commit
    • Alec Theriault's avatar
      Properly escape character literals in Haddocks · 173d0cee
      Alec Theriault authored
      Character literals in Haddock should not be written as plain `'\n'` since
      single quotes are for linking identifiers. Besides, since we want the
      character literal to be monospaced, we really should use `@\'\\n\'@`.
      
      [skip ci]
      173d0cee
  15. 14 Feb, 2019 1 commit
  16. 06 Jan, 2019 1 commit
  17. 22 Nov, 2018 1 commit
  18. 17 Sep, 2018 1 commit
  19. 21 Aug, 2018 1 commit
    • Alec Theriault's avatar
      Fix ambiguous/out-of-scope Haddock identifiers · ddffa0cd
      Alec Theriault authored
      This drastically cuts down on the number of Haddock warnings when making
      docs for `base`.  Plus this means more actual links end up in the docs!
      Also fixed other small mostly markup issues in the documentation along
      the way.
      
      This is a docs-only change.
      
      Reviewers: hvr, bgamari, thomie
      
      Reviewed By: thomie
      
      Subscribers: thomie, rwbarton, carter
      
      Differential Revision: https://phabricator.haskell.org/D5055
      ddffa0cd
  20. 15 May, 2018 1 commit
    • Azel's avatar
      Calling GetLastError() on Windows for socket IO (trac issue #12012) · 01b15b88
      Azel authored
      For the threaded RTS, putting a private copy of the throwErrno
      series in GHC.IO.FD which gets if the operation was on a socket,
      so that we can call c_maperrno if need be.
      For the non-threaded RTS, if memory serves we call GetLastError()
      in case of an error on socket IO. However, we don't do the translation
      ErrCode  Errno currently (and besides, it's a primop) so we do it if
      needed through c_maperrno_func in the asynchronous read/write
      functions.
      Signed-off-by: Azel's avatarARJANEN Loïc Jean David <arjanen.loic@gmail.com>
      
      Reviewers: ekmett, hvr, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie, carter
      
      GHC Trac Issues: #12012
      
      Differential Revision: https://phabricator.haskell.org/D4639
      01b15b88
  21. 13 Apr, 2018 1 commit
  22. 02 Mar, 2018 1 commit
  23. 11 Dec, 2017 3 commits
  24. 24 Nov, 2017 1 commit
    • Niklas Hambüchen's avatar
      base: fdReady(): Fix timeouts > ~49 days overflowing. Fixes #14262. · f209e667
      Niklas Hambüchen authored
      On 64-bit UNIX and Windows, Haskell `Int` has 64 bits
      but C `int msecs` has 32 bits, resulting in an overflow.
      
      This commit fixes it by switching fdReady() to take int64_t,
      into which a Haskell `Int` will always fit.
      
      (Note we could not switch to `long long` because that is
      32 bit on 64-bit Windows machines.)
      
      Further, to be able to actually wait longer than ~49 days,
      we put loops around the waiting syscalls (they all accept only
      32-bit integers).
      
      Note the timer signal would typically interrupt the syscalls
      before the ~49 days are over, but you can run Haskell programs
      without the timer signal, an we want it to be correct in all
      cases.
      
      Reviewers: bgamari, austin, hvr, NicolasT, Phyx
      
      Reviewed By: bgamari, Phyx
      
      Subscribers: syd, Phyx, rwbarton, thomie
      
      GHC Trac Issues: #14262
      
      Differential Revision: https://phabricator.haskell.org/D4011
      f209e667
  25. 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
  26. 30 Oct, 2017 2 commits
  27. 03 Oct, 2017 1 commit
  28. 29 Aug, 2017 1 commit
  29. 27 Jul, 2017 1 commit
    • Andreas Klebinger's avatar
      Initialize hs_init with UTF8 encoded arguments on Windows. · 7af0b906
      Andreas Klebinger authored
      Summary:
      Get utf8 encoded arguments before we call hs_init and use them
      instead of ignoring hs_init arguments. This reduces differing
      behaviour of the RTS between windows and linux and simplifies
      the code involved.
      
      A few testcases were changed to expect the same result on windows
      as on linux after the changes.
      
      This fixes #13940.
      
      Test Plan: ./validate
      
      Reviewers: austin, hvr, bgamari, erikd, simonmar, Phyx
      
      Subscribers: Phyx, rwbarton, thomie
      
      GHC Trac Issues: #13940
      
      Differential Revision: https://phabricator.haskell.org/D3739
      7af0b906
  30. 04 May, 2017 1 commit
    • Takenobu Tani's avatar
      Fix comment for compact region · 4fcaf8e9
      Takenobu Tani authored
      There were old module names:
      
       * Data.Compact -> GHC.Compact
       * Data.Compact.Internal -> GHC.Compact
      
      This commit is for ghc-8.2 branch.
      
      Test Plan: build
      
      Reviewers: austin, bgamari, hvr, erikd, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3522
      4fcaf8e9
  31. 29 Apr, 2017 1 commit
  32. 23 Apr, 2017 1 commit
  33. 22 Apr, 2017 1 commit
  34. 21 Apr, 2017 1 commit
  35. 22 Mar, 2017 1 commit
    • David Feuer's avatar
      Make unsafeInterleaveST less unsafe · 30d68d63
      David Feuer authored
      * Make `unsafeInterleaveST` use `noDuplicate#` like
      `unsafeInterleaveIO` does to prevent the suspended action from
      being run in two threads.
      
      * In order to accomplish this without `unsafeCoerce#`, generalize
      the type of `noDuplicate#`.
      
      * Add `unsafeDupableInterleaveST` to get the old behavior.
      
      * Document unsafe `ST` functions and clean up some related
      documentation.
      
      Fixes #13457
      
      Reviewers: austin, hvr, bgamari, ekmett
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3370
      30d68d63