Skip to content

Conversation

@akoeplinger
Copy link
Member

The root cause of the problem in #50388 turned out to be because we do not have pthread_condattr_setclock(..., CLOCK_MONOTONIC); on iOS.
This caused the timeout argument for pthread_cond_timedwait to be interpreted as an absolute system time (in seconds since the Unix epoch), however the value we got back from clock_gettime(CLOCK_MONOTONIC, ...) was actually some value based on the uptime of the system.
Since the uptime is much smaller than the system time the wait immediately returned.

Harden the handling by adding a check for HAVE_PTHREAD_CONDATTR_SETCLOCK like we already do in SystemNative_LowLevelMonitor_Create()

The root cause of the problem in dotnet#50388 turned out to be because we do not have `pthread_condattr_setclock(..., CLOCK_MONOTONIC);` on iOS.
This caused the timeout argument for `pthread_cond_timedwait` to be interpreted as an _absolute system time_ (in seconds since the Unix epoch), however the value we got back from `clock_gettime(CLOCK_MONOTONIC, ...)` was actually some value based on the uptime of the system.
Since the uptime is much smaller than the system time the wait immediately returned.

Harden the handling by adding a check for `HAVE_PTHREAD_CONDATTR_SETCLOCK` like we already do in `SystemNative_LowLevelMonitor_Create()`
Copy link
Contributor

@CoffeeFlux CoffeeFlux left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this!

@steveisok steveisok self-requested a review March 30, 2021 19:30
@akoeplinger akoeplinger merged commit 6d817d9 into dotnet:main Mar 30, 2021
@akoeplinger akoeplinger deleted the add-monotonic-check branch March 30, 2021 23:42
@steveisok
Copy link
Member

/backport to release/6.0-preview3

@github-actions
Copy link
Contributor

Started backporting to release/6.0-preview3: https://github.com/dotnet/runtime/actions/runs/705796245

@ghost ghost locked as resolved and limited conversation to collaborators May 19, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants