1. 02 Jan, 2021 1 commit
  2. 26 Nov, 2020 1 commit
  3. 25 Nov, 2020 5 commits
    • Matthew Pickering's avatar
      Add test for whereFrom# · 6b27de7e
      Matthew Pickering authored
    • Matthew Pickering's avatar
      Add whereFrom and whereFrom# primop · 6ba68bd2
      Matthew Pickering authored
      The `whereFrom` function provides a Haskell interface for using the
      information created by `-finfo-table-map`. Given a Haskell value, the
      info table address will be passed to the `lookupIPE` function in order
      to attempt to find the source location information for that particular closure.
      At the moment it's not possible to distinguish the absense of the map
      and a failed lookup.
    • Matthew Pickering's avatar
      Add option to give each usage of a data constructor its own info table · 08339a7d
      Matthew Pickering authored
      The `-fdistinct-constructor-tables` flag will generate a fresh info
      table for the usage of any data constructor. This is useful for
      debugging as now by inspecting the info table, you can determine which
      usage of a constructor caused that allocation rather than the old
      situation where the info table always mapped to the definition site of
      the data constructor which is useless.
      In conjunction with `-hi` and `-finfo-table-map` this gives a more fine
      grained understanding of where constructor allocations arise from in a
    • Matthew Pickering's avatar
      Add -finfo-table-map which maps info tables to source positions · 1b99f17e
      Matthew Pickering authored
      This new flag embeds a lookup table from the address of an info table
      to information about that info table.
      The main interface for consulting the map is the `lookupIPE` C function
      > InfoProvEnt * lookupIPE(StgInfoTable *info)
      The `InfoProvEnt` has the following structure:
      > typedef struct InfoProv_{
      >     char * table_name;
      >     char * closure_desc;
      >     char * ty_desc;
      >     char * label;
      >     char * module;
      >     char * srcloc;
      > } InfoProv;
      > typedef struct InfoProvEnt_ {
      >     StgInfoTable * info;
      >     InfoProv prov;
      >     struct InfoProvEnt_ *link;
      > } InfoProvEnt;
      The source positions are approximated in a similar way to the source
      positions for DWARF debugging information. They are only approximate but
      in our experience provide a good enough hint about where the problem
      might be. It is therefore recommended to use this flag in conjunction
      with `-g<n>` for more accurate locations.
      The lookup table is also emitted into the eventlog when it is available
      as it is intended to be used with the `-hi` profiling mode.
      Using this flag will significantly increase the size of the resulting
      object file but only by a factor of 2-3x in our experience.
    • Matthew Pickering's avatar
      Profiling by info table mode (-hi) · 682be07a
      Matthew Pickering authored
      This profiling mode creates bands by the address of the info table for
      each closure. This provides a much more fine-grained profiling output
      than any of the other profiling modes.
      The `-hi` profiling mode does not require a profiling build.
  4. 19 Nov, 2020 5 commits
    • Matthias Andreas Benkard's avatar
      Document loadFramework changes. (#18446) · 07c5acae
      Matthias Andreas Benkard authored and Ben Gamari's avatar Ben Gamari committed
      Adds commentary on the rationale for the changes made in merge request
    • Matthias Andreas Benkard's avatar
      loadFramework: Output the errors collected in all loading attempts. · 57b5f130
      Matthias Andreas Benkard authored and Ben Gamari's avatar Ben Gamari committed
      With the recent change away from first finding and then loading a
      framework, loadFramework had no way of communicating the real reason
      why loadDLL failed if it was any reason other than the framework
      missing from the file system.  It now collects all loading attempt
      errors into a list and concatenates them into a string to return to
      the caller.
    • Matthias Andreas Benkard's avatar
      macOS: Load frameworks without stating them first. · 3571cc41
      Matthias Andreas Benkard authored and Ben Gamari's avatar Ben Gamari committed
      macOS Big Sur makes the following change to how frameworks are shipped
      with the OS:
      > New in macOS Big Sur 11 beta, the system ships with a built-in
      > dynamic linker cache of all system-provided libraries. As part of
      > this change, copies of dynamic libraries are no longer present on
      > the filesystem. Code that attempts to check for dynamic library
      > presence by looking for a file at a path or enumerating a directory
      > will fail. Instead, check for library presence by attempting to
      > dlopen() the path, which will correctly check for the library in the
      > cache. (62986286)
      Therefore, the previous method of checking whether a library exists
      before attempting to load it makes GHC.Runtime.Linker.loadFramework
      fail to find frameworks installed at /System/Library/Frameworks.
      GHC.Runtime.Linker.loadFramework now opportunistically loads the
      framework libraries without checking for their existence first,
      failing only if all attempts to load a given framework from any of the
      various possible locations fail.
    • Ben Gamari's avatar
      rts: Refactor unloading of foreign export StablePtrs · 65be3832
      Ben Gamari authored
      Previously we would allocate a linked list cell for each foreign export.
      Now we can avoid this by taking advantage of the fact that they are
      already broken into groups.
      (cherry picked from commit 40dc9106)
    • Ben Gamari's avatar
      rts: Refactor foreign export tracking · ed57c3a9
      Ben Gamari authored
      This avoids calling `libc` in the initializers which are responsible for
      registering foreign exports. We believe this should avoid the corruption
      observed in #18548.
      See Note [Tracking foreign exports] in rts/ForeignExports.c for an
      overview of the new scheme.
      (cherry picked from commit c4921349)
  5. 18 Nov, 2020 1 commit
    • Andreas Klebinger's avatar
      NCG: Fix 64bit int comparisons on 32bit x86 · 410b43a2
      Andreas Klebinger authored and Ben Gamari's avatar Ben Gamari committed
      We no compare these by doing 64bit subtraction and
      checking the resulting flags.
      We used to do this differently but the old approach was
      broken when the high bits compared equal and the comparison
      was one of >= or <=.
      The new approach should be both correct and faster.
      (cherry picked from commit bb100805)
      (cherry picked from commit fda3e50b)
  6. 14 Nov, 2020 2 commits
    • Ben Gamari's avatar
      rts/linker: Fix relocation overflow in PE linker · 36c1027d
      Ben Gamari authored
      Previously the overflow check for the IMAGE_REL_AMD64_ADDR32NB
      relocation failed to account for the signed nature of the value.
      Specifically, the overflow check was:
          uint64_t v;
          v = S + A;
          if (v >> 32) { ... }
      However, `v` ultimately needs to fit into 32-bits as a signed value.
      Consequently, values `v > 2^31` in fact overflow yet this is not caught
      by the existing overflow check.
      Here we rewrite the overflow check to rather ensure that
      `INT32_MIN <= v <= INT32_MAX`. There is now quite a bit of repetition
      between the `IMAGE_REL_AMD64_REL32` and `IMAGE_REL_AMD64_ADDR32` cases
      but I am leaving fixing this for future work.
      This bug was first noticed by @awson.
      Fixes #15808.
      (cherry picked from commit 6d21ecee535782f01dba9947a49e282afee25724)
    • Ben Gamari's avatar
      testsuite: Add test for #18346 · f96d6cd7
      Ben Gamari authored
      This was fixed by 4291bdda.
      (cherry picked from commit ee5dcdf9)
  7. 01 Nov, 2020 1 commit
  8. 23 Oct, 2020 1 commit
    • toonn's avatar
      Fix typos in 8.10.2 changelog · 929e09ed
      toonn authored and Ben Gamari's avatar Ben Gamari committed
      Replace an "as well" missing "as" with "and" in 4.1 Highlights.
      Add missing apostrophe in "user's guide", insert space in "work around"
      and dash in "cost-center" in 4.2.2 Runtime system.
  9. 22 Oct, 2020 1 commit
  10. 20 Oct, 2020 1 commit
    • Tamar Christina's avatar
      rts: fix race condition in StgCRun · 658362c6
      Tamar Christina authored and Ben Gamari's avatar Ben Gamari committed
      On windows the stack has to be allocated 4k at a time, otherwise we get
      a segfault. This is done by using a helper ___chkstk_ms that is provided
      by libgcc. The Haskell side already knows how to handle this but we need
      to do the same from STG. Previously we would drop the stack in StgRun
      but would only make it valid whenever the scheduler loop ran.
      This approach was fundamentally broken in that it falls apart when you
      take a signal from the OS. We see it less often because you initially
      get allocated a 1MB stack block which you have to blow past first.
      Concretely this means we must always keep the stack valid.
      Fixes #18601.
      (cherry picked from commit fd984d68)
  11. 15 Oct, 2020 10 commits
  12. 14 Oct, 2020 1 commit
    • Moritz Angermann's avatar
      [macOS] improved runpath handling · 43f97049
      Moritz Angermann authored and Ben Gamari's avatar Ben Gamari committed
      In b592bd98 we started using
      -dead_strip_dylib on macOS when lining dynamic libraries and binaries.
      The underlying reason being the Load Command Size Limit in macOS
      Sierra (10.14) and later.
      GHC will produce @rpath/libHS... dependency entries together with a
      corresponding RPATH entry pointing to the location of the libHS...
      library. Thus for every library we produce two Load Commands.  One to
      specify the dependent library, and one with the path where to find it.
      This makes relocating libraries and binaries easier, as we just need to
      update the RPATH entry with the install_name_tool. The dynamic linker
      will then subsitute each @rpath with the RPATH entries it finds in the
      libraries load commands or the environement, when looking up @rpath
      relative libraries.
      -dead_strip_dylibs intructs the linker to drop unused libraries. This in
      turn help us reduce the number of referenced libraries, and subsequently
      the size of the load commands.  This h...
  13. 08 Oct, 2020 1 commit
  14. 06 Oct, 2020 3 commits
    • GHC GitLab CI's avatar
      configure: Avoid hard-coded ld path on Windows · fec3a3cf
      GHC GitLab CI authored and Ben Gamari's avatar Ben Gamari committed
      The fix to #17962 ended up regressing on Windows as it failed to
      replicate the logic responsible for overriding the toolchain paths on
      Windows. This resulted in a hard-coded path to a directory that likely
      doesn't exist on the user's system (#18550).
      (cherry picked from commit 34e0fa96)
    • Ömer Sinan Ağacan's avatar
      Fix uninitialized field read in Linker.c · 8a85216c
      Ömer Sinan Ağacan authored and Ben Gamari's avatar Ben Gamari committed
      Valgrind report of the bug when running the test `linker_unload`:
          ==29666== Conditional jump or move depends on uninitialised value(s)
          ==29666==    at 0x369C5B4: setOcInitialStatus (Linker.c:1305)
          ==29666==    by 0x369C6C5: mkOc (Linker.c:1347)
          ==29666==    by 0x36C027A: loadArchive_ (LoadArchive.c:522)
          ==29666==    by 0x36C0600: loadArchive (LoadArchive.c:626)
          ==29666==    by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload)
          ==29666== Conditional jump or move depends on uninitialised value(s)
          ==29666==    at 0x369C5B4: setOcInitialStatus (Linker.c:1305)
          ==29666==    by 0x369C6C5: mkOc (Linker.c:1347)
          ==29666==    by 0x369C9F6: preloadObjectFile (Linker.c:1507)
          ==29666==    by 0x369CA8D: loadObj_ (Linker.c:1536)
          ==29666==    by 0x369CB17: loadObj (Linker.c:1557)
          ==29666==    by 0x3866BC: main (linker_unload.c:33)
      The problem is `mkOc` allocates a new `ObjectCode` and calls
      `setOcInitialStatus` without initializing the `status` field.
      `setOcInitialStatus` reads the field as first thing:
          static void setOcInitialStatus(ObjectCode* oc) {
              if (oc->status == OBJECT_DONT_RESOLVE)
              if (oc->archiveMemberName == NULL) {
                  oc->status = OBJECT_NEEDED;
              } else {
                  oc->status = OBJECT_LOADED;
      `setOcInitialStatus` is unsed in two places for two different purposes:
      in `mkOc` where we don't have the `status` field initialized yet (`mkOc`
      is supposed to initialize it), and `loadOc` where we do have `status`
      field initialized and we want to update it. Instead of splitting the
      function into two functions which are both called just once I inline the
      functions in the use sites and remove it.
      Fixes #18342
      (cherry picked from commit 08c1cb0f)
    • Ben Gamari's avatar
      Bump text submodule to · a259e6da
      Ben Gamari authored
      Fixes #18588 and #17956.
  15. 12 Sep, 2020 1 commit
  16. 29 Aug, 2020 1 commit
    • Vladislav Zavialov's avatar
      Import qualified Prelude in Cmm/Parser.y · e512d310
      Vladislav Zavialov authored and Krzysztof Gogolewski's avatar Krzysztof Gogolewski committed
      In preparation for the next version of 'happy', c95920 added a qualified
      import to GHC/Parser.y but for some reason neglected GHC/Cmm/Parser.y
      This patch adds the missing qualified import to GHC/Cmm/Parser.y and
      also adds a clarifying comment to explain why this import is needed.
      (cherry picked from commit fddddbf4)
  17. 22 Aug, 2020 2 commits
  18. 09 Aug, 2020 2 commits