[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 42 commits: Move idle GC tracking to its own file, step 1 of 2
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 59cd0c9b by Duncan Coutts at 2026-11-28T17:06:41-05:00 Move idle GC tracking to its own file, step 1 of 2 Add a new IdleGC.{c,h} module. Move the RecentActivity type, recent_activity variable and {get,set}RecentActivity wrappers. - - - - - 469e750d by Duncan Coutts at 2026-11-28T17:06:41-05:00 Move idle GC functionality to its own file, step 2 of 2 We can now fully encapsulate the recent_activity state, exposing just three hooks, and one query used in the scheduler and timer tick. This is a prelude to making changes to the implementation of tracking when to perform an idle gc. - - - - - e9601ff6 by Duncan Coutts at 2026-11-28T17:06:41-05:00 Correct comments in idle GC code The comments still referred to stopTimer/startTimer. These were replaced recently by pauseTimer/unpauseTimer, but the comment was not updated. - - - - - a13e31c6 by Duncan Coutts at 2026-11-28T17:06:41-05:00 Make signal handling be a responsibility of the I/O manager(s) Previously it was scattered between I/O managers and the scheduler, and especially the scheduler's deadlock detection. Previously the scheduler would poll for pending signals each iteration of the scheduler loop. The scheduler also had some hairy signal functionality in the deadlock detection: in the non-threaded RTS (only) if there were still no threads running after deadlock detection then it would block waiting for signals. But signals can and (in my opinion) should be thought of as just a funny kind of I/O, and thus should be a responsibility of the I/O manager. So now we have the I/O managers poll for signals when they are polling for I/O completion (and removing the separate poll in the scheduler). And when I/O managers block waiting for I/O then they now also start signal handlers if they get interrupted by a signal. Crucially, if there is no pending I/O or timers, the awaitCompletedTimeoutsOrIO will still block waiting for signals. This patch puts us into an intermediate state: it temporarily breaks deadlock detection in the non-threaded RTS. The waiting on I/O currently happens before deadlock detection. This means we'll now wait forever on signals before doing deadlock detection. We need to move waiting after deadlock detection. We'll do that in a later patch. - - - - - 38ed5896 by Duncan Coutts at 2026-11-28T17:06:41-05:00 Clean up the RTS internal signal handling API Now that the I/O manager is responsible for signals, we can simplify the API we present for signal handling. We now just need startPendingSignalHandlers, which is called from the I/O managers. We can get rid of awaitUserSignals. We also don't need RtsSignals.h to re-export the platform-specific posix/Signals.h or win32/ConsoleHandler.h We can also hide more of the implementation of signals. Less has to be exposed in posix/Signals.h or win32/ConsoleHandler.h. Indeed, posix/Signals.h becomes empty and we remove it. Partly this is because we don't need inline functions (or macros) in the interface. Also remove signal_handlers from RTS ABI exported symbols list. It does not appear to have any users in the core libs, and its really an internal implementation detail. It should not be exposed unless it's really necessary. - - - - - 197543a6 by Duncan Coutts at 2026-11-28T17:06:41-05:00 Remove variable n_haskell_handlers which has become write-only The previous commit removed the last read of this variable. - - - - - fb028cfd by Duncan Coutts at 2026-11-28T17:06:41-05:00 Narrow the window in which signals might be missed before poll/select Any signals delivered just before poll/select block will be missed until they are woken later by unrelated events. This arbitrarily delays the delivery of signals. This is not a complete solution. It is a cheap way to narrow but not close the window. A full solution will have to come later. This issue existed already, and is documented in issue #27540. - - - - - 6134b823 by Duncan Coutts at 2026-11-28T17:06:41-05:00 In the scheduler, move I/O blocking after deadlock detection To make deadlock detection effective in the non-threaded RTS when there are deadlocked threads and other unrelated threads waiting on I/O, we need to arrange to do deadlock detection before we block in scheduler to wait on I/O. The solution is to: 1. adjust scheduleFindWork, which runs before deadlock detection, to only poll for I/O and not block; and 2. add a step after deadlock detection to wait on I/O if there are still no threads to run (and there's any I/O or timeouts outstanding) The scheduleCheckBlockedThreads is now so simple that it made more sense to inline it into scheduleFindWork. - - - - - f0070c0c by Duncan Coutts at 2026-11-28T17:06:41-05:00 Remove bogus anyPendingTimeoutsOrIO guard from scheduleDetectDeadlock The deadlock detection was only invoked if both of these conditions hold: 1. the run queue is empty 2. there is no pending I/O or timeouts The second condition is unnecessary. The deadlock detection mechanism can find deadlocks even if there are other threads waiting on I/O or timers. Having this extra condition means that we fail to detect blocked threads if there are any threads waiting on I/O or timers. Part of fixing issue #26408 - - - - - 232907db by Duncan Coutts at 2026-11-28T17:06:41-05:00 Don't consider pending I/O for early context switch optimisation Context switches are normally initiated by the timer signal. If however the user specifies "context switch as often as possible", with +RTS -C0 then the scheduler arranges for an early context switch (when it's just about to run a Haskell thread). Context switching very often is expensive, so as an optimisation there cases where we do not arrange an early context switch: 1. if there's no other threads to run 2. if there is no pending I/O or timers This patch eliminates case 2, leaving only case 1. The rationale is as follows. The use of this was inconsistent across platforms and threaded/non-threaded RTS ways. It only worked on the non-threaded RTS and on Windows only worked for the win32-legacy I/O manager. On all other combinations anyPendingTimeoutsOrIO would always return false. The fact that nobody noticed and complained about this inconsistency suggests that the feature is not relied upon. If however it turns out that applications do rely on this, then the proper thing to do is not to restore this check, but to add a new I/O manager hint function that returns if there is any pending events that are likely to happen *soon*: for example timeouts expiring within one timeslice, or I/O waits on things likely to complete soon like disk I/O, but not for example socket/pipe I/O. The motivation to avoid this use of anyPendingTimeoutsOrIO is to allow us to eliminate anyPendingTimeoutsOrIO entirely. All other uses of this are just guards on {await,poll}CompletedTimeoutsOrIO and the guards can safely be folded into those functions. This will better cope with some I/O managers having no proper implementation of anyPendingTimeoutsOrIO. Ultimately this will let us simplify the scheduler which currently has to have special #ifdef mingw32_HOST_OS cases to cope with the lack of a working anyPendingTimeoutsOrIO for some Windows I/O managers - - - - - a23f09a9 by Duncan Coutts at 2026-11-28T17:06:41-05:00 Remove anyPendingTimeoutsOrIO guarding {poll,await}CompletedTimeoutsOrIO Previously the API of the I/O manager used a two step process: check anyPendingTimeoutsOrIO and then call {poll,await}CompletedTimeoutsOrIO. This was primarily there as a performance thing, to cheaply check if we need to do anything. And then because anyPendingTimeoutsOrIO existed, it was used for other things too. We have now eliminated the other uses, and are just left with the performance pattern. But this was problematic because not all I/O managers correctly implement anyPendingTimeoutsOrIO (specifically the win32 ones), and now that we also make I/O managers responsible for signals then we need to poll/await even if there is no pending I/O or timeouts. If there is no pending I/O or timeouts then await needs to degenerate to just waiting forever for any signals. - - - - - f0d8e605 by Duncan Coutts at 2026-11-28T17:06:41-05:00 Remove anyPendingTimeoutsOrIO, it is no longer used And this avoids the problems arising from the win32 I/O managers having had a bogus implementation. - - - - - 402a1cb9 by Duncan Coutts at 2026-11-28T17:06:41-05:00 Remove second scheduler call to awaitCompletedTimeoutsOrIO Previously awaitCompletedTimeoutsOrIO was called both before and after deadlock detection in the scheduler. The reason for that was that the win32 I/O managers had a bogus implementation of anyPendingTimeoutsOrIO and this was used to guard the call of awaitCompletedTimeoutsOrIO prior to deadlock detection. This meant the first call site was never actually called when using the win32 I/O managers. This was the reason for the second call: the first one was never used. What a mess. So now we have a simple design in the scheduler: 1. poll for completed I/O, timers or signals 2. if no runnable threads: do deadlock detection 3. if still no runnable threads: block waiting for I/O, timers or signals. - - - - - 8e4fce07 by Duncan Coutts at 2026-11-28T17:06:41-05:00 Lift emptyRunQueue guard out of scheduleDetectDeadlock this improved the clarity of the logic when reading the scheduler code. And improve the comment about scheduleDoGC that was rather unclear. - - - - - 2d61d9ae by Duncan Coutts at 2026-11-28T17:06:41-05:00 Make interruptIOManager work for WinIO (non-threaded) Fixes #27403 The idle GC scheme now fundamentally relies on interruptIOManager working, so it's no longer acceptable for it to be missing for WinIO. Not having it would cause lock ups. - - - - - fb6fa834 by Duncan Coutts at 2026-11-28T17:06:41-05:00 Make non-threaded deadlock detection also rely on idle GC Only do deadlock detection GC when idle GC kicks in. This also relies on using wakeUpRts, so now do this unconditionally. Previously wakeUpRts was for the threaded rts only. - - - - - 72ba6da1 by Duncan Coutts at 2026-11-28T17:06:41-05:00 Enable idle GC by default on non-threaded RTS The behaviour is now uniform between the threaded and non-threaded RTS ways. The deadlock detection now relies on idle GC for both threaded and non-threaded ways. Previously deadlock detection did not rely on idle GC for the non-threaded way. Also tweak test T7275 to account for idle GC. This test's output is sensitive to the number of major GCs run. Since this commit enables idle GC for the non-threaded RTS, for this test that increases the number of major GCs, since the test program is frequently idle for more than 300ms. - - - - - aba09e28 by Duncan Coutts at 2026-11-28T17:06:41-05:00 Fix state of idle GC control vars with +RTS -V0 Currently when the user uses +RTS -I0, then doIdleGC is set to false. But if the master tick interval -V is set to 0 then the idleGCDelayTime was being set to 0 but doIdleGC was not being set to false, which is inconsistent, and almost certainly buggy. - - - - - b364dd2e by Duncan Coutts at 2026-11-28T17:06:41-05:00 Add a long Note [Deadlock detection] It describes the historical and modern designs and their trade-offs. The point is we've now unified the code for deadlock detection between the threaded and non-threaded ways, by changing the non-threaded to follow the same design as the threaded. - - - - - 55f8f115 by Duncan Coutts at 2026-11-28T17:06:42-05:00 Refactor the utils providing the I/O timeout for different system APIs We have to provide a timeout in three different time formats (int milliseconds, struct timeval *, and struct timespec *). These are for platform APIs including poll, select, ppoll, pselect, epoll_wait, epoll_wait2 and in future kevent and io_uring. Previously we had one util for each format that both worked out what the timeout should be and converted it into the particular format. This duplicates some logic and it also makes it awkward to modify the timeout value (since there's no common format). Modifying the timeout value is exactly what we want to do, in a subsequent commit, where we want to adjust the timeout to take account of idle GC. - - - - - 3d11b728 by Duncan Coutts at 2026-11-28T17:06:42-05:00 Update the old select I/O manager to use the new timeout utils This will make it much easier to adjust the timeout to take account of idle GC. - - - - - 46e80d3e by Duncan Coutts at 2026-11-28T17:06:42-05:00 Add opportunistic deadlock detection without idle GC Our general design is now that comprehensive deadlock detection relies on idle GC. This allows us to detect partial deadlocks that are not system deadlocks. But it's not prompt. It's a nice to have feature to be able to promptly detect the cases that are system deadlocks. There's no hope to do this in the threaded RTS with -N > 1, but it can be done for the non-threaded RTS and _could_ be done for the threaded RTS with -N1. We can integrate this feature into the general design without too many contortions. We just need the I/O managers to check before sleeping if they would be about to sleep indefinately with no I/O and no registered signal handlers. If so, they can notify the idle GC that we're deadlocked and we schedule and idle GC. - - - - - 59f89a87 by Duncan Coutts at 2026-11-28T17:06:42-05:00 Add idle GC mode for !HAVE_PREEMPTION We have to do idle GC (and thus deadlock detection) differently when we do not have the ticker and the ability to interrupt the I/O manager when it's blocking. - - - - - 18f10e31 by Duncan Coutts at 2026-11-28T17:06:42-05:00 Add and use USED_IF_PREEMPTION to avoid warnings - - - - - 833c84e3 by Duncan Coutts at 2026-11-28T17:06:42-05:00 Add performDeadlockDetection and export via ghc-experimental When documenting the idle GC and deadlock detection behaviour in the user guide, it becomes obiovus that in some cases one would want manual control over deadlock detection. In particular, for applications that disable idle GC, for debugging or robustness, they may want to invoke deadlock detecting GC manually. Bind it in ghc-internal GHC.Internal.System.Mem and re-export via ghc-experimental in System.Mem.Experimental. It is clearly implementation specific behaviour, especially since in GHC the deadlock detection is tied to doing a major GC. - - - - - 72070a01 by Duncan Coutts at 2026-11-28T17:06:42-05:00 Add tests for deadlock detection, issue #26408 We have three tests: T26408a: make sure that we can detect a /partial deadlock/ that is not also a /system deadlock/ T26408b: make sure that we can detect a /system deadlock/ promptly without relying on idle GC T26408c: make sure that we do not falsely detect a deadlock when there is nothing to do except wait on signals T26408d: test that performDeadlockDetection works T26408e: make sure that we can detect a system deadlock with idle GC disabled, after the idle GC timeout has elapsed. T26408f: same as e but with manually invoked major GC - - - - - f62a057a by Duncan Coutts at 2026-11-28T17:06:42-05:00 Update the user guide with the revised idle GC behaviour It's now not just for the threaded RTS, but general. Add a new section in the RTS chapter: Idle GC and deadlock detection. Provide general documentation on both topics. In particular, document the behaviour of deadlock detection and how it depends on idle GC. Move the existing entries for -I and -Iw to this section. Add a changelog entry. - - - - - 6ae22d34 by Simon Peyton Jones at 2026-11-28T17:06:43-05:00 Make pushCast pure, and move it to Simplify.Utils pushCast and pushCastMCo were in the SimplM monad, but no longer do anything monadic. (Historically, pushing a coercion into an argument used to simplify that argument; but now the coercion is recorded in the sc_cast field of ApplyToVal.) This patch makes them pure functions, and moves them, together with addCastMCo, optOutCoercion and Note [The sc_cast field of ApplyToVal], from GHC.Core.Opt.Simplify.Iteration to GHC.Core.Opt.Simplify.Utils, alongside the SimplCont type they manipulate. No change in behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - 4a0dfb55 by Simon Peyton Jones at 2026-11-28T17:06:43-05:00 Lambda and case binders have vanilla IdInfo (#27965) Lambda binders, case binders, and case-alternative binders should never have RULES, a (non-default) inline pragma, or a stable unfolding. See new Note [Core binder IdInfo invariants] in GHC.Core, which lays out the invariants. This patch * Makes Core Lint check the invariant, using the new predicate GHC.Types.Id.lamBndrInfoOK. * Fixes the desugarer, which violated it. For a strict binding let !x = rhs in body we generate let x = rhs in case x of x { DEFAULT -> body } re-using x (shadowed) as the case binder; see Note [Desugar Strict binds]. But the case binder inherited x's IdInfo, including, say, a NOINLINE pragma (e.g. `res1` in GHC.Internal.Control.Monad.ST.Lazy.Imp). Now GHC.HsToCore.Utils.seqVar gives the case binder vanilla IdInfo. This was not just a matter of taste. For example h fm s = let {-# NOINLINE res1 #-} !res1 = fm s !(f, s') = res1 in (f+1, s') The NOINLINE case binder becomes a NOINLINE alias `let res3 = res2`, which is never inlined, and survives (as a silly join point) into the final code. * Fixes the Simplifier, which could violate it when duplicating a StrictBind continuation, which makes a join point let x = <> in b ==> join j x = b in j <> If x has any IdInfo that isn't allowed in a lambda-binder, we now zap the IdInfo in the join point: let x = <> in b ==> join j x' = b in j <> where x' is like x (definitely the same unique) but with zapped IdInfo. See (SB3) in Note [StrictBind]. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - cac131ec by Simon Peyton Jones at 2026-11-28T17:06:43-05:00 Add varIsHNF, and use it in move_transit_vars `varIsHNF v` is the same as `exprIsHNF (Var v)`, but avoids building the Var only to take it apart. The (Var v) case of exprIsHNFlike now uses the shared varIsHNFlike, so the two cannot drift apart. In GHC.Core.Opt.WorkWrap.Utils.move_transit_vars we had the guard isUnliftedType var_ty || exprIsHNF (Var var) but exprIsHNF is already True of variables of (definitely) unlifted type, so the isUnliftedType test was redundant. Now it is just (varIsHNF var). Also make `exprIsHNFlike` treat an application with no value arguments, such as `f @Int`, exactly like the bare variable `f`, by going through varIsHNFlike. Otherwise no change in behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - 08fc1afe by Simon Peyton Jones at 2026-11-28T17:06:43-05:00 Use SimplClo for the argument of ApplyToVal This patch renames SimplSR to SimplClo (a "closure"), and uses it not only as the range of the Simplifier's substitution, but also as the argument of an ApplyToVal continuation. ApplyToVal used to have three fields sc_env :: StaticEnv sc_arg :: CoreExpr sc_cast :: MOutCoercion but now has just sc_dup :: DupFlag sc_arg :: SimplClo An un-simplified argument is (ContEx env arg mco), and an already-simplified one is (DoneEx arg _). See Note [The argument of ApplyToVal] in GHC.Core.Opt.Simplify.Utils. The main payoff is that, since the substitution maps an Id to a SimplClo, beta-reduction can substitute the argument for the lambda binder without further ado. Accordingly, preInlineUnconditionally is split into * preInlineLetUnconditionally, for let-bindings * preInlineBetaUnconditionally, for beta-redexes, which takes a SimplClo The latter omits some checks that cannot fire for lambda binders. Other notes * The new (ContEx env arg mco) form makes it easy to push a cast into an argument (mkCloCastMCo), whether or not it has been simplified. See Note [The MOutCoercion field of ContEx]. * `preInlineUnconditionally` gets split into two variants, one for let-bindings and one for beta-reduction (which takes a `SimplClo`). There is a little bit of duplication here, but not much. * Fixes #27962. The simplifier was previously dropping a cast when dealing with runRW#. The new `SimplClo` makes that bug much harder to allow. * Fixes #27963. contOutArgs, which supplies the arguments for Plan (BEFORE) rule matching, ignored the sc_cast field of ApplyToVal. So in (f |> co) n ==> f (n |> co1) -- co1 in sc_cast a rule for `f` saw `f n` rather than `f (n |> co1)`, and failed to match (the rule matcher checks the types of template variables). If f's unfolding is active, f may then be inlined, and the rule is lost for good. Now contOutArgs uses simplCloExpr, which includes the pending cast. Almost no change in behaviour, except for the #27963 bug-fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - 7d3e1349 by Simon Peyton Jones at 2026-11-28T17:06:43-05:00 Add splitThunkCpr This commit adds GHC.Core.Opt.WorkWrap.splitThunkCpr, which adds a form of "thunk splitting" for strict bindings that have CPR information. See Note [Thunk splitting] in WorkWrap.hs for the details. It catches a previously-unrecognised optimisation opportunity (see #28158) but it only helps in fairly obscure cases, so I don't expect a big impact in practice. As usually I did lots of refactoring along the way. LLM disclosure: lots of interaction with Claude, but I wrote all the code and comments. - - - - - 4beaa4ad by sheaf at 2026-11-28T17:06:51-05:00 Make FunDepEqns a non-empty list This avoids creating a 'FunDepEqns' with no equations. This means that consumers dealing with [FunDepEqns] can reliably use "null fun_dep_eqns" to decide whether there are any equations. - - - - - 89eb3448 by sheaf at 2026-11-28T17:06:51-05:00 tryFamEqFunDeps: (CF1) only for closed tyfams This commit makes (CF1) in Note [Exploiting closed type families] only apply to *closed* type families, not *open* type families. This allows the program reported in #28082 to continue to be accepted, fixing a regression. Fixes #28082 - - - - - 35099246 by Rodrigo Mesquita at 2026-11-28T17:06:52-05:00 test: make T3171 not fragile and add version for ext interp too - actually test the sleep of the user-given expression gets interrupted - the ext interp version tests two things: - Requests can be cancelled without terminating the ext interp (#18852) - The stmt being evaluated gets interrupted in the ext interp (that is, ^C gets sent to the thread running the user-given expression and doesn't affect the ext interp main thread) - testing ext interp requires sending ^C to whole process group Fixes #15383 - - - - - 173ce280 by Rodrigo Mesquita at 2026-11-28T17:06:52-05:00 Global break action which uses a per-thread context map Previously, everytime an expression was run in the interpreter (`sandboxIO`): 1) the RTS global variable `rts_breakpoint_io_action`, which is run anytime any thread hits a breakpoint, got set to a new action that: a) Wrote the breakpoint hit by the thread to the `statusMVar` b) Blocked waiting on a newly created MVar `breakMVar` for a `resumeStmt` to signal it. 2) Start the expression evaluation on a new "sandbox" thread 3) Block waiting on `statusMVar` for a breakpoint to be hit, and we'd return the read `EvalBreak` 4) Set the `rts_breakpoint_io_action` to a no-op which prints "Ignored breakpoint..." At some later point, we could `resumeStmt` with the `EvalBreak` context by signaling the `breakMVar` on which the thread that hit the breakpoint is blocked. However, if you consider an expression which forks off threads which hit breakpoints, surprising things may happen: main = do -- the `worker` code has a breakpoint mapM (forkIO . worker) [1..10] forever $ threadDelay 10000000 Interpreting this program, we'll do (1,2,3), and all workers will hit their breakpoint and run `rts_breakpoint_io_action`. Here's a first issue: 1. The first worker succeeds in `putMVar statusMVar` 2. The interpreter will read `takeMVar statusMVar` (3) and then (4) 3. The remaining workers are hitting the breakpoint concurrently: - Some may block trying to `putMVar statusMVar` - Some may run the no-op action which discards the breakpoint Depending on whether the remaining workers hit the breakpoint or (4) happens first, some workers will skip their breakpoint. Now, let's pretend all workers can block on `putMVar statusMVar`. Since the interpreter will take the breakpoints one by one, and resume them one by one, it seemingly works. However, that's only fine when we assume only one expression is evaluated at once. As soon as multiple expressions can be evaluated at once (a desireable property of a debugger, as well as something that can already happen today in some scenarios (see `break049`)), it becomes madness: The second issue comes the global break action being swapped by a second evaluation and threads from the first evaluation running the "wrong" action. Consider: 1. eval `expr_A` installs a break action that puts on `statusMVar_A` 2. `expr_A` forks off a few threads, they're running in the background 3. eval `expr_B` sets the break action to put on `statusMVar_B` 4. the `expr_A` forked threads hit a breakpoint and put `statusMVar_B` 5. `expr_B` returns with a breakpoint of `expr_A`, `resume expr_B` would resume `expr_A`, etc... A third issue with having a single MVar for all threads of an execution is that there is no way to have fine-grained control over which threads are resumed and which are stopped. This is often necessary to debug multi-threaded programs too. Therefore, it is imperative that the global break action does not capture a global single MVar when many expressions with many corresponding threads can be running in the interpreter/debugger at once, if we want to support debugging multi-threaded programs at all. --- This commit fixes these foundational issues by making the global break action truly global (i.e. never modified and never capturing any locals). The global break action is installed once in `sandboxIO` and never removed (`withBreakAciton` and `noBreakAction` were killed). Subsequent runs of `sandboxIO` re-rewrite the same break action (a no-op). When any thread hits the global break action, it looks its `ThreadId` up in the global per-thread context mapping, returning a `ResumeContext` which contains that thread's `breakMVar` (now `resumeBreakVar`) and `statusMVar` (now `resumeEvalStatus`). Each thread blocks on its own MVar and replies on its own TVar. There is no longer one global status nor break MVar. To resume a thread by its `ThreadId`, we can simply fetch its `ResumeContext` and signal the corresponding `resumeBreakMVar` To wait for a result or for a breakpoint in a specific thread, we do `readThreadEvalStatus`. To wait for any breakpoint hit in any thread at all, we have `readAnyThreadEvalBreak`. Some evaluations will only care to look at their own result and breaks (so they run with `readAllBreaks` `= False`); and the main thread of an evaluation should not be read by other evaluations. In short, only threads forked off by the main thread of evaluations get read with `readAnyThreadEvalBreak`. If two evaluations fork off threads in the background, `readAnyThreadEvalBreak` may return threads from any of them. There is no just way to distinguish their "parents" at runtime. For instance, `compileParsedExprRemote` should run an expression until completion without any existing threads interfering with its execution, so it runs with `readAllBreaks = False`. Otherwise, by default, running `main` on the REPL, we'll want to stop at any break any forked thread hits, just like we did before. P.S. Currently, we need to keep track of the "main expression thread" being currently evaluated to fetch its result, but, when `evalStmt` becomes asynchronous by returning the `ThreadId` of the "sandbox" thread, the whole `evaluationMainThreadGlobalVar` hack can be deleted. --- New tests observing behavior that we don't want to break (which I broke at some point while developing this patch): - break032: we don't stop at breakpoints in TH - break033: :continue after -fbreak-on-exception doesn't hit exception breakpoint - break034: test :abandon doesn't hang with -fbreak-on-error - conc033: also run with the external interpreter - ForceInterrupt(Ext): ^C during :force interrupts the forced expression - break043: :continue of a forked thread reads main thread breaks/results too - break046: evaluating expr while stopped doesn't change what :continue resumes - break048: evaluating expr while forked thread is stopped doesn't hit again current breakpoint New tests that failed before this commit: - T3171(ext)nosandbox: T3171 with -fno-ghci-sandbox (T3171extnosandbox still fails) - break050(ext): ^C during :continue of a forked thread interrupts that thread Fixed ext-interp bc. resumeStmt now does unsafeUnmask, just like sandboxIO, so the UserInterrupt reaches the resume. - break049: breakpoints in forked threads don't get mixed up with other evaluations This test demonstrates one way multi-threaded debugging can go wrong bc the global break action used to capture a break MVar for a specific thread that is shared by all threads (described above as "the second issue"). Here is the annotated execution of the test *before this commit*: ```haskell ghci> main Stopped in Main.inMain, break049.hs:30:12-18 _result :: IO () = _ [break049.hs:30:12-18] ghci> :force slow -- ANN: the breakpoint we're ignoring on :force is the worker's -- breakpoint, and it's just discarded *** Ignoring breakpoint [break049.hs:27:14-20] slow = 5 [break049.hs:30:12-18] ghci> :cmd return "" -- ANN: we :continue `main`, but the worker should still be blocked -- so `main` should block. [break049.hs:30:12-18] ghci> :continue -- ANN: however, it completes; recall the worker break was ignored -- instead of stopping there main done -- ANN: after this commit, the worker break wouldn't have been read -- by `:force`, and we'd see it when resuming `:main`, and -- `:continue` here would resume the worker and only then main would -- complete. ghci> :continue -- ANN: bc this is ghci before the commit, we see: not stopped at a breakpoint ghci> ``` - break042: main forks workers and all workers hit a breakpoint This test witnesses "the first issue" described above, where the workers hit breaks after the global break action was already removed and so are lost. Fixes #28124 - - - - - 5cc59f4b by Rodrigo Mesquita at 2026-11-28T17:06:52-05:00 ci: unset CI_COMMIT_MESSAGE to avoid Windows environment length limits The previous commit consistently made the Windows runner fail with:
find: The environment is too large for exec().
GitLab sets these environment variables by default, but we never read them. Just unset them at the start. - - - - - 8f0ce127 by Sylvain Henry at 2026-11-28T17:06:58-05:00 x86-64 NCG: check that address displacements fit in 32 bits (#28105) Three clauses of getAmode put a constant in the displacement of an address without a valid check that it fits in a signed 32-bit integer, so the assembler rejected the module: - x + ((y << shift) + offset): the guard checked the offset only for shift 3, because && binds tighter than ||. - CmmRegOff x offset + (y << shift): no check. - x - lit: the guard checked lit, but the displacement is -lit, which does not fit for lit = -2^31. Each clause now checks the constant that goes in the displacement and narrows it to the target word width, as litToImm does: the Integer of a CmmInt can be out of the range of its width, and truncation with the host Int is wrong for a 64-bit host that compiles for a 32-bit target. When the constant does not fit, the clause does not match and a later clause computes it in a register. See Note [Displacements fit in 32 bits]. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> - - - - - dd10d0e7 by David Eichmann at 2026-11-28T17:06:59-05:00 testsuite: fix framework failure on window for tests using all_available_io_managers_except() - - - - - 092ba893 by David Eichmann at 2026-11-28T17:07:00-05:00 testsuite: use `all_available_io_managers` for various tests Affected tests: * T10590 * T21969 * T21969a * T21969b * T21969c * T21969d * T21969e * T21969f - - - - - fb98e45b by Sylvain Henry at 2026-11-28T17:07:05-05:00 testsuite: Do not pass $(WAY_FLAGS) to GHCi in Makefile tests (#28166) Since 543c108e6a9 the driver sets WAY_FLAGS for Makefile tests. Some GHCi tests passed $(WAY_FLAGS) to ghc --interactive, where it was empty before. In the optasm and optllvm ways it now contains -O, and the byte-code backend ignores -O with a -Winconsistent-flags warning. This warning made the tests fail. Pass $(WAY_FLAGS) to the compilation steps only. GHCi reuses the object files that these steps make with -O, thus the tests stay useful in the optimised ways. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - dd3d2d34 by Alan Zimmerman at 2026-11-28T17:07:07-05:00 EPA: Introduce LayoutFrame stacks in ExactPrint state The exact print process keeps the current layout offset in its state, for use in printing and updating for makeDelta. Update it to use a stack rather than a single value, so it properly handles nested layout, in particular when the layout is introduced but the printing is empty. Also simplify the exact print repl test runner to use a relative path to the GHC libdir. - - - - - 163 changed files: - .gitlab/ci.sh - + changelog.d/28105 - + changelog.d/28124 - + changelog.d/T27962 - + changelog.d/T27963 - + changelog.d/T28082 - + changelog.d/idle-gc-and-deadlock-detection - compiler/GHC/Builtin/WiredIn/Ids.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make/Box.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Config.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Eval/Types.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Instance/FunDeps.hs - compiler/GHC/Tc/Solver/FunDeps.hs - compiler/GHC/Types/Cpr.hs - compiler/GHC/Types/Id.hs - compiler/GHC/Types/Id/Info.hs - compiler/GHC/Utils/Monad.hs - docs/users_guide/profiling.rst - docs/users_guide/runtime_control.rst - libraries/ghc-experimental/src/System/Mem/Experimental.hs - libraries/ghc-internal/src/GHC/Internal/System/Mem.hs - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/Run.hs - + libraries/ghci/GHCi/Run/Breakpoints.hs - libraries/ghci/ghci.cabal.in - rts/Capability.c - rts/IOManager.c - rts/IOManager.h - + rts/IdleGC.c - + rts/IdleGC.h - rts/Interpreter.c - rts/Linker.c - rts/RtsFlags.c - rts/RtsSignals.h - rts/RtsStartup.c - rts/RtsSymbols.c - rts/Schedule.c - rts/Schedule.h - rts/Timer.c - rts/include/rts/OSThreads.h - rts/include/rts/storage/GC.h - rts/js/environment.js - rts/posix/Poll.c - rts/posix/Poll.h - rts/posix/Select.c - rts/posix/SelectBis.c - rts/posix/SelectBis.h - rts/posix/Signals.c - − rts/posix/Signals.h - rts/posix/Timeout.c - rts/posix/Timeout.h - rts/rts.cabal - rts/win32/AsyncMIO.c - rts/win32/AsyncMIO.h - rts/win32/AsyncWinIO.c - rts/win32/AsyncWinIO.h - rts/win32/AwaitEvent.c - rts/win32/ConsoleHandler.c - rts/win32/ConsoleHandler.h - testsuite/driver/testutil.py - + testsuite/tests/codeGen/should_compile/T28105.cmm - + testsuite/tests/codeGen/should_compile/T28105b.hs - testsuite/tests/codeGen/should_compile/all.T - testsuite/tests/concurrent/should_run/all.T - testsuite/tests/ghci.debugger/scripts/Makefile - testsuite/tests/ghci.debugger/scripts/T14690.stdout - testsuite/tests/ghci.debugger/scripts/all.T - testsuite/tests/ghci.debugger/scripts/break024.stdout - + testsuite/tests/ghci.debugger/scripts/break032.hs - + testsuite/tests/ghci.debugger/scripts/break032.script - + testsuite/tests/ghci.debugger/scripts/break032.stdout - + testsuite/tests/ghci.debugger/scripts/break033.hs - + testsuite/tests/ghci.debugger/scripts/break033.script - + testsuite/tests/ghci.debugger/scripts/break033.stdout - + testsuite/tests/ghci.debugger/scripts/break034.hs - + testsuite/tests/ghci.debugger/scripts/break034.script - + testsuite/tests/ghci.debugger/scripts/break034.stdout - + testsuite/tests/ghci.debugger/scripts/break042.hs - + testsuite/tests/ghci.debugger/scripts/break042.script - + testsuite/tests/ghci.debugger/scripts/break042.stderr - + testsuite/tests/ghci.debugger/scripts/break042.stdout - + testsuite/tests/ghci.debugger/scripts/break043.hs - + testsuite/tests/ghci.debugger/scripts/break043.script - + testsuite/tests/ghci.debugger/scripts/break043.stdout - + testsuite/tests/ghci.debugger/scripts/break046.hs - + testsuite/tests/ghci.debugger/scripts/break046.script - + testsuite/tests/ghci.debugger/scripts/break046.stdout - + testsuite/tests/ghci.debugger/scripts/break048.hs - + testsuite/tests/ghci.debugger/scripts/break048.script - + testsuite/tests/ghci.debugger/scripts/break048.stdout - + testsuite/tests/ghci.debugger/scripts/break049.hs - + testsuite/tests/ghci.debugger/scripts/break049.script - + testsuite/tests/ghci.debugger/scripts/break049.stdout - + testsuite/tests/ghci.debugger/scripts/break050.hs - + testsuite/tests/ghci.debugger/scripts/break050.script - + testsuite/tests/ghci.debugger/scripts/break050.stdout - + testsuite/tests/ghci.debugger/scripts/break050ext.stdout - testsuite/tests/ghci/prog-mhu005/Makefile - testsuite/tests/ghci/prog-mhu006/Makefile - testsuite/tests/ghci/prog-mhu007/Makefile - testsuite/tests/ghci/prog020/Makefile - testsuite/tests/ghci/prog022/Makefile - testsuite/tests/ghci/prog025/Makefile - + testsuite/tests/ghci/should_run/ForceInterrupt.script - + testsuite/tests/ghci/should_run/ForceInterrupt.stdout - + testsuite/tests/ghci/should_run/ForceInterruptExt.stdout - testsuite/tests/ghci/should_run/Makefile - testsuite/tests/ghci/should_run/T3171.stdout - + testsuite/tests/ghci/should_run/T3171ext.stdout - + testsuite/tests/ghci/should_run/T3171extnosandbox.stdout - + testsuite/tests/ghci/should_run/T3171nosandbox.stdout - testsuite/tests/ghci/should_run/all.T - + testsuite/tests/indexed-types/should_compile/T28082.hs - testsuite/tests/indexed-types/should_compile/all.T - testsuite/tests/interface-stability/ghc-experimental-exports.stdout - testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32 - testsuite/tests/profiling/should_run/Makefile - testsuite/tests/rts/Makefile - + testsuite/tests/rts/T26408a.hs - + testsuite/tests/rts/T26408a.stderr - + testsuite/tests/rts/T26408b.hs - + testsuite/tests/rts/T26408b.stderr - + testsuite/tests/rts/T26408c.hs - + testsuite/tests/rts/T26408c.stdout - + testsuite/tests/rts/T26408d.hs - + testsuite/tests/rts/T26408d.stderr - + testsuite/tests/rts/T26408e.hs - + testsuite/tests/rts/T26408e.stderr - + testsuite/tests/rts/T26408f.hs - + testsuite/tests/rts/T26408f.stderr - testsuite/tests/rts/all.T - testsuite/tests/rts/symbols/rts-check-symbols.stdout - testsuite/tests/simplCore/should_compile/T15445.stderr - + testsuite/tests/simplCore/should_compile/T27962.hs - + testsuite/tests/simplCore/should_compile/T27963.hs - + testsuite/tests/simplCore/should_compile/T27963.stderr - + testsuite/tests/simplCore/should_compile/T27965.hs - + testsuite/tests/simplCore/should_compile/T27965a.hs - + testsuite/tests/simplCore/should_compile/T27965b.hs - + testsuite/tests/simplCore/should_compile/T28158.hs - + testsuite/tests/simplCore/should_compile/T28158.stderr - testsuite/tests/simplCore/should_compile/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/774c721ac80b81670875cfb97435dc6... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/774c721ac80b81670875cfb97435dc6... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Marge Bot (@marge-bot)