Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-11625] SyntaxRewriter crashes when called from a thread other than main #413

swift-ci opened this issue Oct 17, 2019 · 4 comments


Copy link

@swift-ci swift-ci commented Oct 17, 2019

Previous ID SR-11625
Radar None
Original Reporter benpious (JIRA User)
Type Bug

SwiftSyntax 0.50100.0, Xcode 11.1. Made a simple SwiftPM project, used generate-xcodeproj to make a project to open (double-clicking the Package.swift file did not produce a buildable project).

Additional Detail from JIRA
Votes 0
Component/s SwiftSyntax
Labels Bug
Assignee None
Priority Medium

md5: 9e3f668e7cbc4a6d8fd8813e5c6f08ad

Issue Description:

I'm trying to create and use a SyntaxRewriter subclass from a thread other than main. I'm not sharing between threads, so it seems like it should be fine. However, I get an EXEC_BAD_ACCESS inside of SwiftSyntax. Here's some sample code that demonstrates the problem, which is adapted from the SwiftSyntax README's sample code:

let string = """

protocol P {
    var x: Int? { get set }


let queue =
let sourceFile = try! SyntaxParser.parse(source: string)
let semaphore = DispatchSemaphore(value: 0)
queue.async {
    _ = Renamer().visit(sourceFile)

It crashes with an EXEC_BAD_ACCESS, typically in `SyntaxRewriter.visitChildren()`. Trying to print any variables in the debugger outputs "Trying to put the stack in unreadable memory at <some memory address>".

I can't reproduce this in an optimized build.

Copy link

@marcelofabri marcelofabri commented Feb 3, 2020

I think this is a duplicate of There's a workaround mentioned there and the root issue should be fixed in master.

Copy link
Contributor Author

@swift-ci swift-ci commented Mar 12, 2020

Comment by Ben Pious (JIRA)

It does look that way. Thanks for pointing me in the right direction!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
Copy link

@Overcot Overcot commented May 20, 2022

I Guess the issue should be marked as resolved? Because in corresponding issues in JIRA all issues seems to be resolved

Copy link

@ahoppen ahoppen commented May 20, 2022

@ahoppen ahoppen closed this as completed May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

5 participants