summaryrefslogtreecommitdiff
path: root/rts
Commit message (Collapse)AuthorAgeFilesLines
* Fix two bugs in stg_ap_0_fast in profiling runtimeÖmer Sinan Ağacan2019-02-201-7/+11
| | | | | | | | | | | | | | | | | | This includes two bug fixes in profiling version of stg_ap_0_fast: - PAPs allocated by stg_ap_0_fast are now correctly tagged. This invariant is checked in Sanity.c:checkPAP. (This was originally implemented in 2693eb11f5, later reverted with ab55b4ddb7 because it revealed the bug below, but it wasn't clear at the time whether the bug was the one below or something in the commit) - The local variable `untaggedfun` is now marked as a pointer so it survives GC. With this we finally fix all known bugs caught in #15508. `concprog001` now works reliably with prof+threaded and prof runtimes (with and without -debug).
* Fix checkStackChunk() call in Interepter.c, enable an assertionÖmer Sinan Ağacan2019-02-132-2/+2
| | | | Fixes #16303
* rts/ProfilerReportJson: Fix format stringBen Gamari2019-02-081-1/+1
| | | | This was warning on i386.
* Don't use X86_64_ELF_NONPIC_HACK for +RTS -xpZejun Wu2019-01-301-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When `+RTS -xp` is passed, when don't need the X86_64_ELF_NONPIC_HACK, becasue the relocation offset should only be out of range if * the object file was not compiled with `-fPIC -fexternal-dynamic-refs`; * ghc generates non-pic code while it should (e.g. #15723) In either case, we should print an error message rather that silently attempt to use a hacky workaround that may not work. This could have made debugging #15723 and #15729 much easier. Test Plan: Run this in a case where ghci used to crash becasue of T15723. Now we see helpful message like: ``` ghc-iserv-prof: R_X86_64_PC32 relocation out of range: stmzm2zi4zi4zi1zmJQn4hNPyYjP5m9AcbI88Ve_ControlziConcurrentziSTMziTMVar_readTMVar_C61n_cc = 9b95ffac ``` Reviewers: simonmar, bgamari, erikd Reviewed By: simonmar, bgamari Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5233
* Allocate bss section within proper range of other sectionsZejun Wu2019-01-3011-72/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This re-applies {D5195} and {D5235}, they were reverted as part of diff stack to unbreak i386. The proper fix is done in {D5289}. Allocate bss section within proper range of other sections: * when `+RTS -xp` is passed, allocate it contiguously as we did for jump islands * when we mmap the code to lower 2Gb, we should allocate bss section there too Test Plan: 1. `./validate` 2. with ``` DYNAMIC_GHC_PROGRAMS = NO DYNAMIC_BY_DEFAULT = NO ``` `TEST="T15729" make test` passed in both linux (both i386 and x86_64) and macos. 3. Also test in a use case where we used to encouter error like: ``` ghc-iserv-prof: R_X86_64_PC32 relocation out of range: (noname) = b90282ba ``` and now, everything works fine. Reviewers: simonmar, bgamari, angerman, erikd Reviewed By: simonmar Subscribers: rwbarton, carter GHC Trac Issues: #15729 Differential Revision: https://phabricator.haskell.org/D5290
* Add a RTS option -xp to load PIC object anywhere in address spaceZejun Wu2019-01-305-92/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This re-applies {D5195} with fixes for i386: * Fix unused label warnings, see {D5230} or {D5273} * Fix a silly bug introduced by moving `#if` {P190} Add a RTS option -xp to load PIC object anywhere in address space. We do this by relaxing the requirement of <0x80000000 result of `mmapForLinker` and implying USE_CONTIGUOUS_MMAP. We also need to change calls to `ocInit` and `ocGetNames` to avoid dangling pointers when the address of `oc->image` is changed by `ocAllocateSymbolExtra`. Test Plan: See {D5195}, also test under i386: ``` $ uname -a Linux watashi-arch32 4.18.5-arch1-1.0-ARCH #1 SMP PREEMPT Tue Aug 28 20:45:30 CEST 2018 i686 GNU/Linux $ cd testsuite/tests/th/ && make test ... ``` will run `./validate` on stacked diff. Reviewers: simonmar, bgamari, alpmestan, trommler, hvr, erikd Reviewed By: simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5289
* Revert "Batch merge"Ben Gamari2019-01-3012-203/+158
| | | | This reverts commit 76c8fd674435a652c75a96c85abbf26f1f221876.
* Batch mergeBen Gamari2019-01-3012-158/+203
|
* A few typofixesGabor Greif2019-01-231-1/+1
|
* Extend linker-script workaround to work with musl libcSamuel Holland2019-01-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | GHC has code to handle unsuffixed .so files that are linker scripts pointing to the real shared library. The detection is done by parsing the result of `dlerror()` after calling `dlopen()` and looking for certain error strings. On musl libc, the error message is "Exec format error", which happens to be `strerror(ENOEXEC)`: ``` $ cat tmp.c #include <dlfcn.h> #include <stdio.h> int main(void) { dlopen("libz.so", RTLD_NOW | RTLD_GLOBAL); puts(dlerror()); return 0; } $ gcc -o tmp tmp.c $ ./tmp Error loading shared library libz.so: Exec format error $ ``` This change fixes the workaround to also work on musl libc. Link: https://phabricator.haskell.org/D5474
* RTS: Use ELF v1 convention on all powerpc64 systemsPeter Trommler2019-01-171-5/+0
|
* doc: reorder heap profiling information in +RTS -?Ben Price2019-01-161-6/+5
|
* rts: Allow heap prof by closure type in prof wayBen Price2019-01-161-0/+1
| | | | | | Complete b7b6617a90824303daf555c817f538cd9c792671 (see ticket #15086) to actually enable profiling by closure type in the profiling rts. I.e. +RTS -p -hT is now accepted.
* rts: Use always-available locking operations in pthread Itimer implementationBen Gamari2019-01-141-6/+6
| | | | | | Previously we ACQUIRE_LOCK and RELEASE_LOCK but these compile to a noop in the non-threaded RTS, as noted in #16150. Use OS_ACQUIRE_LOCK and OS_RELEASE_LOCK instead.
* itimer: Don't free condvar until we know ticker is stoppedBen Gamari2019-01-141-2/+2
| | | | | | | | | | | When we are shutting down the pthread ticker we signal the start_cond condition variable to ensure that the ticker thread wakes up and exits in a reasonable amount of time. Previously, when the ticker thread would shut down it was responsible for freeing the start_cond condition variable. However, this would lead to a race wherein the ticker would free start_cond, then the main thread would try to signal it in an effort to wake the ticker (#16150). Avoid this by moving the mutex destruction to the main thread.
* Fix checkPtrInArenaÖmer Sinan Ağacan2019-01-131-2/+11
| | | | (See comments)
* Fix negative mutator time in GC stats in prof buildsÖmer Sinan Ağacan2019-01-123-49/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because garbage collector calls `retainerProfile()` and `heapCensus()`, GC times normally include some of PROF times too. To fix this we have these lines: // heapCensus() is called by the GC, so RP and HC time are // included in the GC stats. We therefore subtract them to // obtain the actual GC cpu time. stats.gc_cpu_ns -= prof_cpu; stats.gc_elapsed_ns -= prof_elapsed; These variables are later used for calculating GC time excluding the final GC (which should be attributed to EXIT). exit_gc_elapsed = stats.gc_elapsed_ns - start_exit_gc_elapsed; The problem is if we subtract PROF times from `gc_elapsed_ns` and then subtract `start_exit_gc_elapsed` from the result, we end up subtracting PROF times twice, because `start_exit_gc_elapsed` also includes PROF times. We now subtract PROF times from GC after the calculations for EXIT and MUT times. The existing assertion that checks INIT + MUT + GC + EXIT = TOTAL now holds. When we subtract PROF numbers from GC, and a new assertion INIT + MUT + GC + PROF + EXIT = TOTAL also holds. Fixes #15897. New assertions added in this commit also revealed #16102, which is also fixed by this commit.
* Fix raiseAsync() UNDERFLOW_FRAME handling in profiling runtimeÖmer Sinan Ağacan2019-01-121-7/+6
| | | | | | | UNDERFLOW_FRAMEs don't have profiling headers so we have to use the AP_STACK's function's CCS as the new frame's CCS. Fixes one of the many bugs caught by concprog001 (#15508).
* Documentation and refactoring in CCS related codeÖmer Sinan Ağacan2019-01-122-33/+56
| | | | | | | | | - Remove REGISTER_CC and REGISTER_CCS macros, add functions registerCC and registerCCS to Profiling.c. - Reduce scope of symbols: CC_LIST, CCS_LIST, CC_ID, CCS_ID - Document CC_LIST and CCS_LIST
* Implement a sanity check for CCS fields in profiling buildsÖmer Sinan Ağacan2019-01-105-0/+44
| | | | | This helped me debug one of the bugs in #15508. I'm not sure if this is a good idea, but it worked for me, so wanted to submit this as a MR.
* Minor refactoring and documentation in profiling RTS codeÖmer Sinan Ağacan2019-01-031-41/+20
|
* PPC NCG: Remove Darwin supportPeter Trommler2019-01-017-416/+47
| | | | | | | Support for Mac OS X on PowerPC has been dropped by Apple years ago. We follow suit and remove PowerPC support for Darwin. Fixes #16106.
* rts: fix build failure on OpenBSD (_DYNAMIC symbol collision)Sergei Trofimovich2018-12-291-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Build failure on OpenBSD-6.4 the the following: ``` rts/RtsSymbols.c:994:1: error: error: redefinition of '_DYNAMIC' as different kind of symbol | 994 | RTS_OPENBSD_ONLY_SYMBOLS | ^ RTS_OPENBSD_ONLY_SYMBOLS ^ ``` On OpenBSD `_DYNAMIC` was always defined in `<elf.h>` headers but used not to be included. The change explicitly includes `<elf.h>` as a source of symbol definition. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: build-tested on OpenBSD-6.4 Reviewers: bgamari, erikd, simonmar Subscribers: rwbarton, carter GHC Trac Issues: #15945 Differential Revision: https://phabricator.haskell.org/D5461
* rts: Turn ASSERT in LDV_recordDead into a normal ifBen Gamari2018-12-251-1/+3
| | | | | | | | As reported in #15382 the `ASSERT(ctr != NULL)` is currently getting routinely hit during testsuite runs. While this is certainly a bug I would far prefer getting a proper error message than a segmentation fault. Consequently I'm turning the `ASSERT` into a proper `if` so we get a proper error in non-debug builds.
* Fix warning that 'hugs-options' isn't supported any moreGabor Greif2018-12-191-1/+0
|
* StgCRun: Disable unwinding on DarwinBen Gamari2018-12-171-2/+12
| | | | See #15207.
* Use https links in user-facing startup and error messagesBen Gamari2018-12-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | I consider myself lucky that in my circle of friends, `http` urls (as opposed to `https` urls) are frowned upon in that we generally apologize in the rase cases that we share an `http` url. This pull request changes `http` links into their `https` analogues in the following places: * In the GHCI startup message (and parts of the User's Guide, where there are verbatim transcripts of GHCi sessions). * In a couple of error messages, asking the user to report a bug. (I also took the liberty to change a single space before the reportabug url into two spaces, harmonizing this occurence with the others.) I'm not trying to start a war. I just had a moment to spare and felt like preparing this diff. Merge or don't merge as you wish! Reviewers: bgamari, erikd, simonmar Subscribers: goldfire, rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5450
* rts: Annotate fallthroughs in AArch64 linkerBen Gamari2018-12-141-1/+6
|
* Update -F RTS help:Ömer Sinan Ağacan2018-12-141-3/+4
| | | | | | | | | | | | | | - Add default value - Update the help line as multiple short lines instead of one long line, for consistency with other lines. Reviewers: simonmar, bgamari, erikd Reviewed By: bgamari Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5445
* RetainerProfiler: Update retainer profiler debuggingAlexander Vershilov2018-12-121-125/+85
| | | | | | | | | | | | | Debug code have not been updated for a long time, now it's changed to it compiles with recent RTS. Reviewers: bgamari, erikd, simonmar Reviewed By: simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5369
* Typo fix, replace a foldl with foldl'Ömer Sinan Ağacan2018-12-121-1/+1
|
* Fix uninformative hp2ps error when the cmdline contains double quotesZejun Wu2018-12-111-8/+22
| | | | | | | | | | | | | | | | | | | | | | | Reapply D5346 with fix incompatible shell quoting in tests. It seems like `$'string'` is not recognized under all test environments, so let's avoid it in tests. Test Plan: ``` hp2ps: "T15904".hp, line 2: integer must follow identifier ``` use new ghc and hp2ps to profile a simple program. Reviewers: simonmar, bgamari, erikd, tdammers Reviewed By: bgamari Subscribers: tdammers, carter, rwbarton GHC Trac Issues: #15904 Differential Revision: https://phabricator.haskell.org/D5388
* Add +RTS -F to the --help outputSimon Marlow2018-12-111-0/+2
| | | | | | | | | | | | Test Plan: `./inplace/bin/ghc-stage2 +RTS --help" Reviewers: bgamari, sgraf, erikd Reviewed By: sgraf Subscribers: adamse, rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5428
* rts: Ensure that task->id is initializedBen Gamari2018-12-071-0/+1
| | | | | | | | | | Reviewers: erikd, simonmar Reviewed By: simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5325
* Mark SRT_1/SRT_2 as CONSTR_1_0/CONSTR_2_0Ömer Sinan Ağacan2018-12-071-2/+2
| | | | | | | | | | | | | | | Test Plan: Validated locally, but skipped perf tests as there's a framework-related error there. Reviewers: simonmar, bgamari, erikd Reviewed By: simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5421
* Add missing space in report_summary outputAdam Sandberg Eriksson2018-12-071-1/+1
|
* Remove explicit recursion in retainer profiling (fixes #14758)Alexander Vershilov2018-12-051-77/+146
| | | | | | | | | | | | | | | | | | | | | | | Retainer profiling contained a recursion that under certain circumstances could lead to the stack overflow in C code. The idea of the improvement is to keep an explicit stack for the object, more precise to reuse existing stack, but allow new type of objects to be stored there. There is no reliable reproducer that is not a big program but in some cases foldr (+) 0 [1..10000000] can work. Reviewers: bgamari, simonmar, erikd, osa1 Reviewed By: bgamari, osa1 Subscribers: osa1, rwbarton, carter GHC Trac Issues: #14758 Differential Revision: https://phabricator.haskell.org/D5351
* linker: store entire link map and use it.Tamar Christina2018-12-045-20/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes a corner case in which we have seen the symbol multiple times in different static libraries, but due to a depencency we end up loading the symbol from a library other than the first one. Previously the runtime linker would only track symbols from the first library and did not store the full link map. In this case it was unable to find the address for the symbols in the second library during delay loading. This change stores the address of all symbols seen so a full link map is generated, such that when we make a different decision later than what was expected we're able to still correctly load the library. Test Plan: ./validate, new testcase T15894 Reviewers: angerman, bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, carter GHC Trac Issues: #15894 Differential Revision: https://phabricator.haskell.org/D5353
* Hadrian: include 'findPtr' via find-ptr cabal flagAlec Theriault2018-12-041-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is the latest in the 'findPtr' saga. See * 900c47f88784b91517c00be3e1087322e62f698e * 561748cb507505bd5b7bd76bdc57796d896b62a2 for the previous attempts. The problem with re-using the 'debug' cabal flag for the purpose of forcing inclusion of 'findPtr' occurs when 'debug' is one of the RTS ways, but RTS is not being compiled with '-DDEBUG': * the 'debug' flag gets passed to cabal, signalling to build 'rts' with the debug flavour, but also forcing inclusion of the 'findPtr'/'_findPtr' symbol * since '-DDEBUG' isn't enabled, that symbol doesn't show up in the libraries, so executable that depend on 'rts' (everything) will end up always requiring 'findPtr'/'_findPtr' but 'rts' won'y provide it! The fix is simple: create a a new 'find-ptr' cabal-flag whose only purpose is forcing '-Wl,-u,findPtr'/'-Wl,-u,_findPtr'. Then, enable that flag when the RTS is being compiled with '-DDEBUG' Test Plan: ./hadrian/build.sh -c # on mac Reviewers: alpmestan, snowleopard, bgamari, erikd, simonmar, Phyx Reviewed By: alpmestan, snowleopard, Phyx Subscribers: Phyx, rwbarton, carter GHC Trac Issues: #15956 Differential Revision: https://phabricator.haskell.org/D5404
* Hadrian: bump Cabal submodule, install extra dynamic flavours of RTSAlp Mestanogullari2018-11-291-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, Hadrian was building all the appropriate dynamic ways for libHSrts but they were not picked up and installed in the package database when we register the rts library. Since we use Cabal for registering packages and the .cabal files of packages as sources of truth for configuring and installing, we ended up patching Cabal to add a new field, 'extra-dynamic-library-flavours', to specify those extra flavours to install in .cabal files: https://github.com/haskell/cabal/pull/5606 We now make use of this in rts.cabal.in to expose dynamic flavours behind a Cabal flag, which Hadrian will use whenever we are building a GHC flavour that requires dynamic libraries. This is all part of a larger plan to build a dynamic stage 2 GHC by default, like with make, which in turn will fix a lot of test failures. See Test Plan: hadrian/build.sh _build/stage1/lib/package.conf.d/rts-1.0.conf _build/stage1/lib/x86_64-.../ should contain many libHSrts-*.so Reviewers: snowleopard, DavidEichmann, bgamari, erikd, simonmar Reviewed By: snowleopard, DavidEichmann Subscribers: rwbarton, carter GHC Trac Issues: #15837 Differential Revision: https://phabricator.haskell.org/D5385
* Remove unused declarations in MarkWeak.hÖmer Sinan Ağacan2018-11-251-2/+0
|
* Revert "Fix uninformative hp2ps error when the cmdline contains double quotes"Ben Gamari2018-11-241-22/+8
| | | | This reverts commit 390df8b51b917fb6409cbde8e73fe838d61d8832.
* rts/MachO: Iterate through N (all) symbols, not M external symbolsDario Bertini2018-11-221-1/+1
| | | | Fixes #15105
* rts/MachO: A bit of refactoring in ocGetNamesDario Bertini2018-11-221-8/+7
| | | | Eliminates a bit of repetition.
* rts/MachO: Add a bit more debugging output to getNamesDario Bertini2018-11-221-4/+7
|
* Fix uninformative hp2ps error when the cmdline contains double quotesZejun Wu2018-11-221-8/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The format of hp file didn't allow double quotes inside strings, and under prof build, we include args in JOB, which may have double quotes. When this happens, the error message is confusing to the user. This can also happen under normal build if the executable name contains double quite, which is unlikely though. We fix this issue by introducing escaping for double quotes inside a string by repeating it twice. We also fix a buffer overflow bug when the length of the string happen to be multiple of 5000. Test Plan: new tests, which used to fail with error message: ``` hp2ps: "T15904".hp, line 2: integer must follow identifier ``` use new ghc and hp2ps to profile a simple program. Reviewers: simonmar, bgamari, erikd Reviewed By: simonmar Subscribers: rwbarton, carter GHC Trac Issues: #15904 Differential Revision: https://phabricator.haskell.org/D5346
* rts.cabal.in: force inclusion of findPtr/_findPtr symbol only with debug flagAlp Mestanogullari2018-11-223-13/+18
| | | | | | | | | | | | | | | | | The previous strategy caused problems on Windows, as pointed out at [1] [1]: https://phabricator.haskell.org/rGHC900c47f88784#133905 Reviewers: Phyx, bgamari, erikd, simonmar Reviewed By: Phyx Subscribers: rwbarton, carter GHC Trac Issues: #15671 Differential Revision: https://phabricator.haskell.org/D5356
* rts: fix Windows megablock allocatorTamar Christina2018-11-221-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | The megablock allocator does not currently check that after aligning the free region if it still has enough space to actually do the allocation. This causes it to return a memory region which it didn't fully allocate itself. Even worse, it can cause it to return a block with a region that will be present in two allocation pools. This causes if you're lucky an error from the OS that you're committing memory that has never been reserved, or causes random heap corruption. This change makes it consider the alignment as well. Test Plan: ./validate , testcase testmblockalloc Reviewers: bgamari, erikd, simonmar Reviewed By: simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5363
* rts: Fix bss initialization on WindowsTamar Christina2018-11-221-7/+6
| | | | | | | | | | | | | | | | | This patch fixes BSS initialization such that it is initialized to 0 as you'd expect. Test Plan: ./validate, test T7040_ghci Reviewers: bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, carter GHC Trac Issues: #15669 Differential Revision: https://phabricator.haskell.org/D5364
* rts/M32Alloc: Abort if m32 linker mmap failsBen Gamari2018-11-221-0/+3
| | | | Previously we should just blinding dereference a NULL pointer.