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-13628] Deadlock when using the print function #56063
Comments
@swift-ci create |
Comment by Peter Schorn (JIRA) theindigamer (JIRA User) So is this definitely a bug then? Or am I doing something wrong? |
I think it's a bug. Sorry, my previous comment wasn't meant for you: I was cloning the bug to Radar (Apple's internal bug tracker). |
Comment by Peter Schorn (JIRA) I assumed the comment wasn't meant directly for me; I was wondering if it was an indication that this is, in fact, a bug. |
Peter_Schorn (JIRA User) This is not a bug. the reason why print(self.description) does not dead lock, is that description is retrieved before print is called. print(self, to: &self.someString) does not dead lock because it's not printing to Stdout. |
Comment by Peter Schorn (JIRA) @eeckstein Then why is it the case that removing the print statements inside the |
That's a good question. |
Comment by Peter Schorn (JIRA) @eeckstein And let me remind you that using a locking abstraction that allows for recursively taking a lock—such as |
cc kylemacomber (JIRA User) |
Comment by Peter Schorn (JIRA) Any updates on this bug? Has anyone discovered the cause? |
kylemacomber (JIRA User)? |
Comment by Kyle Macomber (JIRA) We'll take a look. |
Environment
MacBook Pro late 2013.
macOS Catalina 10.15.6
Swift 5.3
Additional Detail from JIRA
md5: fb6f9bef31cb1091796bc335465ed993
Issue Description:
I found this really strange bug in which the print function causes a deadlock when called within a dispatch queue.
The deadlock occurs at the line
in AuthorizationManager.description, which is indirectly called by
Intriguingly, changing the above line to any of the following prevents the deadlock:
Furthermore, removing the line
also prevents the deadlock.
I suspect that this bug is related to the fact that the print function is synchronized.
I also tested out other locking mechanisms instead of DispatchQueue, including
NSLock
,NSRecursiveLock
and even this fancy implementation from swift-log, and I experienced the exact same bug.I posted this issue on the swift forums, and a commenter summarized the cause of the bug as follows:
Here is the code that causes the issue:
The text was updated successfully, but these errors were encountered: