Skip to content

fix(pthread): preserve distant timedlock deadlines - #1378

Closed
MarcZX10 wants to merge 1 commit into
boykopovar:mainfrom
MarcZX10:fix/pthread-timedlock-wide-deadline
Closed

MarcZX10 wants to merge 1 commit into
boykopovar:mainfrom
MarcZX10:fix/pthread-timedlock-wide-deadline

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Recompute POSIX pthread mutex waits from the absolute deadline using bounded KernelUseconds chunks.
  • Avoid overflowing host chrono conversions for very distant deadlines and avoid treating one maximum-length wait as the full absolute timeout.

Why

The previous POSIX wrapper converted tv_sec to the host clock duration and capped the relative wait at UINT_MAX microseconds. Very distant valid deadlines could overflow or time out after a single capped wait.

Tests

  • Built guest_kernel_error_tests, guest_pthread_attr_tests, guest_pthread_barrier_tests, guest_pthread_key_tests, guest_pthread_rwlock_tests, guest_pthread_sem_tests, and guest_cond_timedwait_tests on Linux.
  • guest_kernel_errors passed twice; all seven pthread-related CPU-only tests passed.
  • Repository conventions check passed.

Not tested

  • Waiting through the full UINT_MAX-microsecond chunk rollover (the regression test uses tv_sec=INT64_MAX and verifies acquisition after a 2-second owner hold).
  • Windows, socket, GPU/Vulkan, and title/game runs.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Same as #1336: no title is shown waiting on a deadline more than 71 minutes out, and this also turns main's throw for a negative tv_sec into a timeout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants