Skip to content

[windows] NSRecursiveLock: missing initialization of mutex/condition variable #2269

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

Merged
merged 1 commit into from
May 15, 2019
Merged

[windows] NSRecursiveLock: missing initialization of mutex/condition variable #2269

merged 1 commit into from
May 15, 2019

Conversation

lxbndr
Copy link
Contributor

@lxbndr lxbndr commented May 15, 2019

Looks like timeout condition variable and corresponding mutex are not initialized in RSMRecursiveLock implementation. Noticed random but often crashes in our test code. Best reproduced with nested lock/unlock calls

let lock1 = NSRecursiveLock()
let lock2 = NSRecursiveLock()

lock1.lock()
lock2.lock()
lock2.unlock() // <- crash or hang here

Not sure if there is no additional issues though, still getting very rare crashes. But success rate changed from, like, "1 success per 100 failures" to "1 failure per 100 success runs".

@compnerd
Copy link
Member

Um, no, no one would ever write code like that, this is ... yes, yes, something must be wrong with the checkout. sigh At least I got the non-recursive case right? That counts for something right?

@compnerd
Copy link
Member

@swift-ci please test and merge

@@ -234,6 +234,8 @@ open class NSRecursiveLock: NSObject, NSLocking {
super.init()
#if os(Windows)
InitializeCriticalSection(mutex)
InitializeConditionVariable(timeoutCond)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Just realized there is no test for locks. It would be helpful for sure. Should I add test to this particular PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add it in a subsequent PR? My suggestion: I would add the test with this reverted, make sure it fails and then add this back in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, will do.

@swift-ci swift-ci merged commit 17d047b into swiftlang:master May 15, 2019
@lxbndr lxbndr deleted the fix-nsrecursivelock-mutex-init branch May 16, 2019 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants