[Git][ghc/ghc][wip/stack-cloning-segfault] 21 commits: DmdAnal: Take stable unfoldings into account when determining argument demands
Matthew Pickering pushed to branch wip/stack-cloning-segfault at Glasgow Haskell Compiler / GHC Commits: 870243e4 by Zubin Duggal at 2026-03-12T17:33:28+05:30 DmdAnal: Take stable unfoldings into account when determining argument demands Previously, demand analysis only looked at the RHS to compute argument demands. If the optimised RHS discarded uses of an argument that the stable unfolding still needed, it would be incorrectly marked absent. Worker/wrapper would then replace it with LitRubbish, and inlining the stable unfolding would use the rubbish value, causing a segfault. To fix, we introduce addUnfoldingDemands which analyses the stable unfolding with dmdAnal and combines its DmdType with the RHS's via the new `maxDmdType` which combines the demands of the stable unfolding with the rhs, so we can avoid any situation where we give an absent demand to something which is still used by the stable unfolding. Fixes #26416. - - - - - 669d09f9 by Cheng Shao at 2026-03-13T15:06:07-04:00 hadrian: remove redundant library/rts ways definitions from stock flavours This patch removes redundant library/rts ways definitions from stock flavours in hadrian; they can be replaced by applying appropriate filters on `defaultFlavour`. - - - - - a27dc081 by Teo Camarasu at 2026-03-13T15:06:51-04:00 ghc-internal: move bits Weak of finalizer interface to base We move parts of the Weak finalizer interface to `base` only the parts that the RTS needs to know about are kept in `ghc-internal`. This lets us then prune our imports somewhat and get rid of some SOURCE imports. Resolves #26985 - - - - - 6eef855b by Sylvain Henry at 2026-03-13T15:08:18-04:00 Stg/Unarise: constant-folding during unarisation (#25650) When building an unboxed sum from a literal argument, mkUbxSum previously emitted a runtime cast via `case primop [lit] of var -> ...`. This wrapper prevented GHC from recognising the result as a static StgRhsCon, causing top-level closures to be allocated as thunks instead of being statically allocated. Fix: try to perform the numeric literal cast at compile time using mkLitNumberWrap (wrapping semantics). If successful, return the cast literal directly with an identity wrapper (no case expression). The runtime cast path is kept as fallback for non-literal arguments. Test: codeGen/should_compile/T25650 - - - - - 905f8723 by Simon Jakobi at 2026-03-13T15:09:09-04:00 Add regression test for #2057 Test that GHC stops after an interface-file error instead of continuing into the linker. The test constructs a stale package dependency on purpose. `pkgB` is compiled against one version of package `A`, then the same unit id is replaced by an incompatible build of `A`. When `Main` imports `B`, GHC has to read `B.hi`, finds an unfolding that still mentions the old `A`, and should fail while loading interfaces. Closes #2057. Assisted-by: Codex - - - - - a13245a9 by Sylvain Henry at 2026-03-13T15:10:06-04:00 JS: fix recompilation avoidance (#23013) - we were checking the mtime of the *.jsexe directory, not of a file - we were not computing the PkgsLoaded at all - - - - - 07442653 by Cheng Shao at 2026-03-13T15:10:51-04:00 hadrian: bump index state & bootstrap plans This patch bumps hadrian index state & bootstrap plans: - The updated index state allows bootstrapping from 9.14 without cabal allow-newer hacks - The updated bootstrap plans all contain shake-0.19.9 containing important bugfix, allowing a subsequent patch to bump shake bound to ensure the bugfix is included - ghc 9.14.1 bootstrap plan is added - - - - - fdc1dbad by Cheng Shao at 2026-03-13T15:10:51-04:00 ci: add ghc 9.14.1 to bootstrap matrix This patch adds ghc 9.14.1 to bootstrap matrix, so that we test bootstrapping from ghc 9.14.1. - - - - - 91916079 by Sylvain Henry at 2026-03-13T15:11:43-04:00 T17912: wait for opener thread to block before killing it (#24739) Instead of a fixed 1000ms delay, poll threadStatus until the opener thread is in BlockedOnForeignCall, ensuring killThread only fires once the thread is provably inside the blocking open() syscall. This prevents the test from accidentally passing on Windows due to scheduling races. - - - - - baa4ebb4 by Cheng Shao at 2026-03-13T15:12:26-04:00 template-haskell: fix redundant import in Language.Haskell.TH.Quote This patch fixes a redundant import in `Language.Haskell.TH.Quote` that causes a ghc build failure when bootstrapping from 9.14 with validate flavours. Fixes #27014. - - - - - 02e68a86 by Brandon Simmons at 2026-03-13T15:13:19-04:00 Add a cumulative gc_sync_elapsed_ns counter to GHC.Internal.Stats This makes it possible to get an accurate view of time spent in sync phase when using prometheus-style sampling. Previously this was only available for the most recent GC. This intentionally leaves GHC.Stats API unchanged since it is marked as deprecated, and API changes there require CLC approval. Fixes #26944 - - - - - a18fa3c1 by Cheng Shao at 2026-03-14T05:12:14-04:00 configure: make $LLVMAS default to $CC when $CcLlvmBackend is YES This patch changes the $LLVMAS detection logic in configure so that when it's not manually specified by the user, it defaults to $CC if $CcLlvmBackend is YES. It's a more sensible default than auto-detected clang from the environment, especially when cross-compiling, $CC as the cross target's LLVM assembler is more compatible with the use case than the system-wide clang. Fixes #26769. - - - - - 3774086e by Matthew Pickering at 2026-03-14T05:13:00-04:00 exceptions: annotate onException continuation with WhileHandling Before this patch, an exception thrown in the `onException` handler would loose track of where the original exception was thrown. ``` import Control.Exception main :: IO () main = failingAction `onException` failingCleanup where failingAction = throwIO (ErrorCall "outer failure") failingCleanup = throwIO (ErrorCall "cleanup failure") ``` would report ``` T28399: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall: cleanup failure HasCallStack backtrace: throwIO, called at T28399.hs:<line>:<column> in <package-id>:Main ``` notice that the "outer failure" exception is not present in the error message. With this patch, any exception thrown is in the handler is annotated with WhileHandling. The resulting message looks like ``` T28399: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall: cleanup failure While handling outer failure HasCallStack backtrace: throwIO, called at T28399.hs:7:22 in main:Main ``` CLC Proposal: https://github.com/haskell/core-libraries-committee/issues/397 Fixes #26759 - - - - - 63ae8eb3 by Andreas Klebinger at 2026-03-14T05:13:43-04:00 Fix missing profiling header for origin_thunk frame. Fixes #27007 - - - - - 213d2c0e by Cheng Shao at 2026-03-14T05:14:28-04:00 ci: fix ci-images revision The current ci-images revision was a commit on the WIP branch of https://gitlab.haskell.org/ghc/ci-images/-/merge_requests/183, and it's not on the current ci-images master branch. This patch fixes the image revision to use the current tip of ci-images master. - - - - - fc2b083f by Andreas Klebinger at 2026-03-14T05:15:14-04:00 Revert "hadrian/build-cabal: Better respect and utilize -j" This reverts commit eab3dbba79650e6046efca79133b4c0a5257613d. While it's neat this currently isn't well supported on all platforms. It's time will come, but for now I'm reverting this to avoid issues for users on slightly unconvential platforms. This will be tracked at #26977. - - - - - 12a706cf by Cheng Shao at 2026-03-14T16:37:54-04:00 base: fix redundant imports in GHC.Internal.Weak.Finalize This patch fixes redundant imports in GHC.Internal.Weak.Finalize that causes a regression in bootstrapping head from 9.14 with validate flavours. Fixes #27026. - - - - - b5d39cad by Matthew Pickering at 2026-03-14T16:38:37-04:00 Use explicit syntax rather than pure - - - - - 43638643 by Andreas Klebinger at 2026-03-15T18:15:48-04:00 Configure: Fix check for --target support in stage0 CC The check FP_PROG_CC_LINKER_TARGET used $CC unconditionally to check for --target support. However this fails for the stage0 config where the C compiler used is not $CC but $CC_STAGE0. Since we already pass the compiler under test into the macro I simply changed it to use that instead. Fixes #26999 - - - - - 18fd0df6 by Simon Hengel at 2026-03-15T18:16:33-04:00 Fix typo in recursive_do.rst - - - - - 2ff82864 by Matthew Pickering at 2026-03-16T10:00:43+00:00 rts: forward clone-stack messages after TSO migration MSG_CLONE_STACK assumed that the target TSO was still owned by the capability that received the message. This is not always true: the TSO can migrate before the inbox entry is handled. When that happened, handleCloneStackMessage could clone a live stack from the wrong capability and use the wrong capability for allocation and performTryPutMVar, leading to stack sanity failures such as checkStackFrame: weird activation record found on stack. Fix this by passing the current capability into handleCloneStackMessage, rechecking msg->tso->cap at handling time, and forwarding the message if the TSO has migrated. Once ownership matches, use the executing capability consistently for cloneStack, rts_apply, and performTryPutMVar. Fixes #27008 - - - - - 102 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/generate-ci/gen_ci.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Linker/Loader.hs - compiler/GHC/Stg/Pipeline.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Types/Demand.hs - configure.ac - distrib/configure.ac.in - docs/users_guide/exts/recursive_do.rst - hadrian/bootstrap/generate_bootstrap_plans - hadrian/bootstrap/plan-9_10_1.json - hadrian/bootstrap/plan-9_10_2.json - hadrian/bootstrap/plan-9_10_3.json - hadrian/bootstrap/plan-9_12_1.json - hadrian/bootstrap/plan-9_12_2.json - + hadrian/bootstrap/plan-9_14_1.json - hadrian/bootstrap/plan-bootstrap-9_10_1.json - hadrian/bootstrap/plan-bootstrap-9_10_2.json - hadrian/bootstrap/plan-bootstrap-9_10_3.json - hadrian/bootstrap/plan-bootstrap-9_12_1.json - hadrian/bootstrap/plan-bootstrap-9_12_2.json - + hadrian/bootstrap/plan-bootstrap-9_14_1.json - hadrian/build-cabal - hadrian/cabal.project - hadrian/src/Settings/Flavours/Development.hs - hadrian/src/Settings/Flavours/GhcInGhci.hs - hadrian/src/Settings/Flavours/Quick.hs - hadrian/src/Settings/Flavours/QuickCross.hs - hadrian/src/Settings/Flavours/Quickest.hs - libraries/base/changelog.md - libraries/base/src/GHC/Stats.hs - libraries/base/src/GHC/Weak.hs - libraries/base/src/GHC/Weak/Finalize.hs - − libraries/base/src/GHC/Weak/Finalizehs - libraries/base/src/System/Mem/Weak.hs - libraries/base/tests/IO/T17912.hs - libraries/base/tests/IO/all.T - libraries/ghc-internal/CHANGELOG.md - − libraries/ghc-internal/src/GHC/Internal/Conc/Sync.hs-boot - libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs - libraries/ghc-internal/src/GHC/Internal/IO.hs - − libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs-boot - libraries/ghc-internal/src/GHC/Internal/Stats.hsc - libraries/ghc-internal/src/GHC/Internal/TopHandler.hs - libraries/ghc-internal/src/GHC/Internal/Weak.hs - libraries/ghc-internal/src/GHC/Internal/Weak/Finalize.hs - libraries/template-haskell/Language/Haskell/TH/Quote.hs - m4/fp_prog_cc_linker_target.m4 - rts/CloneStack.c - rts/CloneStack.h - rts/Messages.c - rts/Stats.c - rts/StgMiscClosures.cmm - rts/include/RtsAPI.h - testsuite/.gitignore - testsuite/tests/annotations/should_run/all.T - testsuite/tests/codeGen/should_compile/Makefile - + testsuite/tests/codeGen/should_compile/T25650.hs - + testsuite/tests/codeGen/should_compile/T25650.stdout-ws-32 - + testsuite/tests/codeGen/should_compile/T25650.stdout-ws-64 - testsuite/tests/codeGen/should_compile/all.T - testsuite/tests/dmdanal/should_compile/T18894.stderr - + testsuite/tests/dmdanal/should_run/M1.hs - + testsuite/tests/dmdanal/should_run/T26416.hs - + testsuite/tests/dmdanal/should_run/T26416.stdout - testsuite/tests/dmdanal/should_run/all.T - testsuite/tests/dmdanal/sigs/T21081.stderr - − testsuite/tests/driver/OneShotTH.stdout-javascript-unknown-ghcjs - + testsuite/tests/driver/T2057/Makefile - + testsuite/tests/driver/T2057/README.md - + testsuite/tests/driver/T2057/T2057.stderr - + testsuite/tests/driver/T2057/all.T - + testsuite/tests/driver/T2057/app/Main.hs - + testsuite/tests/driver/T2057/pkgA1/A.hs - + testsuite/tests/driver/T2057/pkgA1/pkg.conf - + testsuite/tests/driver/T2057/pkgA2/A.hs - + testsuite/tests/driver/T2057/pkgA2/pkg.conf - + testsuite/tests/driver/T2057/pkgB/B.hs - + testsuite/tests/driver/T2057/pkgB/pkg.conf - + testsuite/tests/driver/T20604/T20604.stdout-javascript-unknown-ghcjs - testsuite/tests/driver/T20604/all.T - testsuite/tests/driver/all.T - testsuite/tests/driver/fat-iface/fat010.stdout-javascript-unknown-ghcjs - testsuite/tests/driver/recomp011/all.T - testsuite/tests/driver/recompHash/recompHash.stdout-javascript-unknown-ghcjs - testsuite/tests/driver/recompNoTH/recompNoTH.stdout-javascript-unknown-ghcjs - − testsuite/tests/driver/th-new-test/th-new-test.stdout-javascript-unknown-ghcjs - + testsuite/tests/exceptions/T26759.hs - + testsuite/tests/exceptions/T26759.stderr - + testsuite/tests/exceptions/T26759a.hs - + testsuite/tests/exceptions/T26759a.stderr - + testsuite/tests/exceptions/T26759a.stdout - testsuite/tests/exceptions/all.T - testsuite/tests/interface-stability/ghc-experimental-exports.stdout - testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32 - testsuite/tests/rts/all.T - + testsuite/tests/rts/cloneThreadStackMigrating.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5b29665891ab33b218e3f6f5de4a7fc... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5b29665891ab33b218e3f6f5de4a7fc... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Matthew Pickering (@mpickering)