Skip to content

fix(pthread): preserve distant POSIX wait deadlines - #1386

Closed
MarcZX10 wants to merge 1 commit into
boykopovar:mainfrom
MarcZX10:fix/posix-absolute-timedwait-deadlines
Closed

MarcZX10 wants to merge 1 commit into
boykopovar:mainfrom
MarcZX10:fix/posix-absolute-timedwait-deadlines

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Compute remaining POSIX absolute wait time from seconds and nanoseconds without converting arbitrary tv_sec values into host nanoseconds.
  • Retry condition-variable, rwlock, and POSIX semaphore waits when a KernelUseconds-bounded chunk expires but the selected clock deadline is still in the future.
  • Add delayed-event regressions for INT64_MAX deadlines and direct tests for exact chunk boundaries and the remaining timeout after one maximum chunk.

Why

The prior helper could overflow while converting a distant absolute deadline and limited each call to one UINT_MAX-microsecond wait, reporting a timeout before the absolute deadline.

Tests

  • The three delayed-event regressions failed against the original implementation, then passed after the change.
  • Built the condition, rwlock, POSIX semaphore, and related pthread test targets on Linux.
  • guest_cond_timedwait, guest_pthread_rwlock, and guest_posix_sem_post passed twice; all nine related CPU-only tests passed.
  • Repository conventions check passed.

Not tested

  • A real wait across the full 71.6-minute UINT_MAX-microsecond chunk. The chunk arithmetic and exact remaining time after one chunk are tested directly; integration tests use a far-future deadline and a 2-second release/post/signal.
  • Windows, PS5 hardware, socket, GPU/Vulkan, and title/game runs.

This complements #1378, which covers the mutex timedlock path; this PR covers condition variables, rwlocks, and POSIX semaphores.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Same as #1336 and #1378, for the cond, rwlock and semaphore waits.

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