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

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

Comments

@swift-ci
Copy link
Contributor

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

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

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 = DispatchQueue.global()
let sourceFile = try! SyntaxParser.parse(source: string)
let semaphore = DispatchSemaphore(value: 0)
queue.async {
    _ = Renamer().visit(sourceFile)
    semaphore.signal()
}
semaphore.wait()
print("done")

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.

@marcelofabri
Copy link

@marcelofabri marcelofabri commented Feb 3, 2020

I think this is a duplicate of https://bugs.swift.org/browse/SR-11170. There's a workaround mentioned there and the root issue should be fixed in master.

@swift-ci
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
@Overcot
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

@ahoppen
Copy link
Collaborator

@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
Labels
bug
Projects
None yet
Development

No branches or pull requests

5 participants