Skip to content

Fix ppc64le stack overflow from deep Sequential chains in graph checking#20028

Open
T-Gro wants to merge 4 commits into
dotnet:mainfrom
T-Gro:t-gro-fix-stack-overflow-ppc64le
Open

Fix ppc64le stack overflow from deep Sequential chains in graph checking#20028
T-Gro wants to merge 4 commits into
dotnet:mainfrom
T-Gro:t-gro-fix-stack-overflow-ppc64le

Conversation

@T-Gro

@T-Gro T-Gro commented Jul 3, 2026

Copy link
Copy Markdown
Member

Fixes #19988

Long statement sequences parse into deeply right-nested SynExpr.Sequential
chains that FileContentMapping.visitSynExpr walked with one nested visit
per element. Under BUILD_USING_MONO each visit runs inside a StackGuard,
and ppc64le's large stack frames deplete the stack between guard checks.
Flattening the chain first — as already done for IfThenElse — halves the
guarded frames per chain and preserves the emitted entry order.

Long statement sequences parse into deeply right-nested SynExpr.Sequential
chains. FileContentMapping.visitSynExpr walks them in CPS, and under
BUILD_USING_MONO each visit runs inside a StackGuard that only checks room
for one more frame. On ppc64le the larger stack frames deplete the stack
between guard checks, causing the compiler to crash while building fsharp.

Flatten the Sequential chain into a flat list and hand the per-element
continuations to Continuation.concatenate, matching the existing handling
for IfThenElse, Tuple and ArrayOrList. This halves the number of guarded
frames for a chain and preserves the emitted entry order.

Fixes dotnet#19988

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.100.md

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread src/Compiler/Driver/GraphChecking/FileContentMapping.fs Outdated
Move the sequential-flattening logic into SyntaxTreeOps as flattenSequentials
(with (|Sequentials|_|) as sugar over it), so FileContentMapping reuses it
instead of a local copy and ParsedInput's duplicate is removed. The exhaustive
match in visitSynExpr keeps the concrete SynExpr.Sequential case.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files label Jul 3, 2026
@T-Gro T-Gro requested a review from abonie July 3, 2026 12:54
@T-Gro T-Gro enabled auto-merge (squash) July 3, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Stack overflow on ppc64le

2 participants