Skip to content

Add precondition guards to pthread_mutex calls #243

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
Jan 3, 2023

Conversation

Danappelxx
Copy link
Contributor

While in the current configuration lock/unlock shouldn't ever fail, it seems polite to guard against basic misuse in debug builds.

While in the current configuration lock/unlock shouldn't ever fail,
it seems polite to guard against basic misuse in debug builds.
@phausler phausler merged commit 3f12423 into apple:main Jan 3, 2023
@kperryua
Copy link
Member

kperryua commented Jan 3, 2023

I think you may want to pull the result of the lock/unlock calls out of the precondition(). According to the docs:

In -Ounchecked builds, condition is not evaluated, but the optimizer may assume that it always evaluates to true. Failure to satisfy that assumption is a serious programming error.

So in -Ounchecked builds, there will be no locking at all in these paths.

@phausler
Copy link
Member

phausler commented Jan 3, 2023

err good call @kperryua; will adjust that

@Danappelxx Danappelxx deleted the precondition-mutex-failure branch January 4, 2023 01:54
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.

3 participants