summaryrefslogtreecommitdiff
path: root/rts
Commit message (Collapse)AuthorAgeFilesLines
* Only gc sparks locally when we can ensure marking is done.Andreas Klebinger2023-01-122-11/+40
| | | | | | | | When performing GC without work stealing there was no guarantee that spark pruning was happening after marking of the sparks. This could cause us to GC live sparks under certain circumstances. Fixes #22528.
* rts: Drop racy assertionBen Gamari2023-01-121-0/+3
| | | | | | | 0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean. However, this isn't necessarily the case since another thread may have raced us to dirty the object.
* Revert "rts: Drop racy assertion"Ben Gamari2023-01-121-3/+0
| | | | | | | The logic here was inverted. Reverting the commit to avoid confusion when examining the commit history. This reverts commit b3eacd64fb36724ed6c5d2d24a81211a161abef1.
* rts, tests: limit thread name length to 15 bytesNicolas Trangez2023-01-092-1/+7
| | | | | | | | | | | | | On Linux, `pthread_setname_np` (or rather, the kernel) only allows for thread names up to 16 bytes, including the terminating null byte. This commit adds a note pointing this out in `createOSThread`, and fixes up two instances where a thread name of more than 15 characters long was used (in the RTS, and in a test-case). Fixes: #22366 Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/22366 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22366#note_460796
* Remove RTS hack for configuringJohn Ericson2023-01-091-0/+36
| | | | | See the brand new Note [Undefined symbols in the RTS] for additional details.
* rts: MUT_VAR is not a StgMutArrPtrsBen Gamari2023-01-061-2/+1
| | | | There was previously a comment claiming that the MUT_VAR closure type had the layout of StgMutArrPtrs.
* Add support for sized literals in the bytecode interpreter.Luite Stegeman2023-01-063-6/+303
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945
* nonmoving: Make free list counter accesses atomicBen Gamari2022-12-231-1/+1
| | | | Since these may race with the allocator(s).
* nonmoving: Fix race in shortcuttingBen Gamari2022-12-232-1/+8
| | | | | We must use an acquire load to read the info table pointer since if we find an indirection we must be certain that we see the indirectee.
* nonmoving: Fix benign race in update remembered set checkBen Gamari2022-12-231-1/+3
| | | | | Relaxed load is fine here since we will take the lock before looking at the list.
* nonmoving: Make bitmap accesses atomicBen Gamari2022-12-231-2/+2
| | | | | | This is a benign race on any sensible hard since these are byte accesses. Nevertheless, atomic accesses are necessary to satisfy TSAN.
* nonmoving: Ensure that we aren't holding locks when closing themBen Gamari2022-12-231-1/+4
| | | | TSAN complains about this sort of thing.
* nonmoving: Refactor update remembered set initializationBen Gamari2022-12-235-34/+66
| | | | | | | This avoids a lock inversion between the storage manager mutex and the stable pointer table mutex by not dropping the SM_MUTEX in nonmovingCollect. This requires quite a bit of rejiggering but it does seem like a better strategy.
* nonmoving: Make segment state updates atomicBen Gamari2022-12-231-1/+1
|
* nonmoving: Fix races in collector status trackingBen Gamari2022-12-232-7/+10
| | | | | | Mark a number of accesses to do with tracking of the status of the concurrent collection thread as atomic. No interesting races here, merely necessary to satisfy TSAN.
* nonmoving: Ensure that mutable fields have acquire barrierBen Gamari2022-12-231-8/+16
|
* nonmoving: Eliminate race in bump_static_flagBen Gamari2022-12-231-8/+10
| | | | | | | To ensure that we don't race with a mutator entering a new CAF we take the SM mutex before touching static_flag. The other option here would be to instead modify newCAF to use a CAS but the present approach is a bit safer.
* nonmoving: Use atomic when looking at bd->genBen Gamari2022-12-231-1/+4
| | | | Since it may have been mutated by a moving GC.
* nonmoving: Fix segment list racesBen Gamari2022-12-232-6/+12
|
* nonmoving: Fix race in marking of blackholesBen Gamari2022-12-232-2/+8
| | | | | We must use an acquire-fence when marking to ensure that the indirectee is visible.
* rts/m32: Fix sanity checkingBen Gamari2022-12-221-1/+1
| | | | | Previously we would attempt to clear pages which were marked as read-only. Fix this.
* rts: Drop paths from configure from cabal fileBen Gamari2022-12-221-4/+0
| | | | | | | | | | | | | | A long time ago we would rely on substitutions from the configure script to inject paths of the include and library directories of libffi and libdw. However, now these are instead handled inside Hadrian when calling Cabal's `configure` (see the uses of `cabalExtraDirs` in Hadrian's `Settings.Packages.packageArgs`). While the occurrences in the cabal file were redundant, they did no harm. However, since b5c714545abc5f75a1ffdcc39b4bfdc7cd5e64b4 they have no longer been interpolated. @mpickering noticed the suspicious uninterpolated occurrence of `@FFIIncludeDir@` in #22595, prompting this commit to finally remove them.
* Don't consider large byte arrays/compact regions pinned.Andreas Klebinger2022-12-221-1/+4
| | | | | Workaround for #22255 which showed how treating large/compact regions as pinned could cause segfaults.
* rts: explicitly store return value of ccall checkClosure to prevent type ↵Ying-Ruei Liang (TheKK)2022-12-211-1/+2
| | | | error (#22617)
* rts/libdw: Silence uninitialized usage warningsBen Gamari2022-12-181-3/+3
| | | | | | | | As noted in #22538, previously some GCC versions warned that various locals in Libdw.c may be used uninitialized. Although this wasn't strictly true (since they were initialized in an inline assembler block) we fix this by providing explicit empty initializers. Fixes #22538
* rts: Drop racy assertionBen Gamari2022-12-181-0/+3
| | | | | | | 0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean. However, this isn't necessarily the case since another thread may have raced us to dirty the object.
* rts: Note race with wakeBlockingQueueBen Gamari2022-12-161-1/+2
|
* rts: Ensure that all accesses to pending_sync are atomicBen Gamari2022-12-161-2/+2
|
* rts: Statically allocate capabilitiesBen Gamari2022-12-163-19/+19
| | | | This is a rather simplistic way of solving #17289.
* rts: Use ordered accesses instead of explicit barriersBen Gamari2022-12-162-8/+6
|
* rts: Fix ordering of makeStableNameBen Gamari2022-12-161-5/+3
|
* rts: Style fixBen Gamari2022-12-161-6/+3
|
* PrimOps: Fix benign MutVar raceBen Gamari2022-12-161-2/+2
| | | | Relaxed ordering is fine here since the later CAS implies a release.
* rts: Encapsulate sched_stateBen Gamari2022-12-1610-42/+53
|
* rts: Encapsulate access to capabilities arrayBen Gamari2022-12-1623-148/+156
|
* rts: Encapsulate recent_activity accessBen Gamari2022-12-165-25/+45
| | | | | This makes it easier to ensure that it is accessed using the necessary atomic operations.
* rts/Timer: Always use atomic operationsBen Gamari2022-12-163-17/+41
| | | | | | As noted in #22447, the existence of the pthread-based ITimer implementation means that we cannot assume that the program is single-threaded.
* rts: Always use atomics for context_switch and interruptBen Gamari2022-12-164-12/+17
| | | | Since these are modified by the timer handler.
* rts: Introduce getNumCapabilitiesBen Gamari2022-12-1632-122/+130
| | | | | | And ensure accesses to n_capabilities are atomic (although with relaxed ordering). This is necessary as RTS API callers may concurrently call into the RTS without holding a capability.
* Improve heap memory barrier NoteBen Gamari2022-12-165-105/+193
| | | | | Also introduce MUT_FIELD marker in Closures.h to document mutable fields.
* rts/stm: Fix memory ordering in readTVarIO#Ben Gamari2022-12-161-2/+1
| | | | See #22421.
* rts: Use fences instead of explicit barriersBen Gamari2022-12-165-31/+44
|
* Introduce SET_INFO_RELEASE for CmmBen Gamari2022-12-163-4/+3
|
* eventlog: Silence spurious data raceBen Gamari2022-12-161-1/+3
|
* rts/ThreadPaused: Ordering fixesBen Gamari2022-12-161-2/+2
|
* rts/Messages: RefactorBen Gamari2022-12-161-27/+20
| | | | This doesn't change behavior but makes the code a bit easier to follow.
* rts: Ensure that global regs are never passed as fun call argsBen Gamari2022-12-151-3/+3
| | | | | This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing].
* codeGen: Introduce ThreadSanitizer instrumentationBen Gamari2022-12-153-0/+45
| | | | | | This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN.
* Fix bound thread statusLuite Stegeman2022-12-091-1/+1
|
* Add support for environments that don't have setImmediateLuite Stegeman2022-12-091-4/+13
|