Skip to content

[SR-12360] SwiftFormat uses a SwiftSyntax tag that can cause stack overflow in debug mode #334

Closed
@swift-ci

Description

@swift-ci
Previous ID SR-12360
Radar rdar://problem/60832848
Original Reporter cukier (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s swift-format
Labels Bug
Assignee @allevato
Priority Medium

md5: 4111fa0935f36cb69278ce6ab26c299c

Issue Description:

Stack overflow 2: revenge of the rdar://55929175

After implementing formatting in sourcekit-lsp I was investigating why it wasn't working for things that are nested four levels deep. After fighting with debugger, I had a hunch that it may be stack overflow. I found a comment in the function that was crashing:

    // The implementation of every generated case goes into its own function. This
    // circumvents an issue where the compiler allocates stack space for every
    // case statement next to each other in debug builds, causing it to allocate
    // ~50KB per call to this function. rdar://55929175

It crashes only in debug mode, on macos

To reproduce:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions