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

Fix core sync test deadlock on darwin #4253

Merged
merged 4 commits into from
Sep 17, 2024
Merged

Conversation

pkova
Copy link
Contributor

@pkova pkova commented Sep 16, 2024

The deadlock was discussed in #4232.

I'm running macos 14.6.1 and __ulock_wait randomly deadlocks in the core sync tests. I guess it shouldn't be too surprising since this isn't really a public API and as the zig guys discovered Apple has been migrating to __ulock_wait2.

In any case using __ulock_wait2 seems to fix the problem. The corresponding change should probably be made to the C++ code as well.

Copy link
Contributor

@Feoramund Feoramund left a comment

Choose a reason for hiding this comment

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

I was going to mention the comment, but it looks like you got it already. Great job and thank you for looking into this.

core/sync/futex_darwin.odin Outdated Show resolved Hide resolved
@laytan
Copy link
Sponsor Collaborator

laytan commented Sep 16, 2024

Great! I wonder, if you do -minimum-os-version:14.4.0 (so it uses the new public os_sync api) does that also not deadlock? I assume it doesn't?

@laytan
Copy link
Sponsor Collaborator

laytan commented Sep 16, 2024

And indeed, would want an improvement like this in the compiler too, but if you aren't comfortable there I can pick that up too.

@pkova
Copy link
Contributor Author

pkova commented Sep 16, 2024

Can confirm no deadlocks with ./odin test tests/core/sync -minimum-os-version:14.4.0.

@laytan
Copy link
Sponsor Collaborator

laytan commented Sep 16, 2024

Another thing catching my eye (clicking through that link) is that ulock_wait is microseconds and ulock_wait2 is nanoseconds. Looks like we handle that wrong here too, passing in nanoseconds where the api expects microseconds.

@gingerBill gingerBill merged commit 4a3b4da into odin-lang:master Sep 17, 2024
7 checks passed
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