Skip to content

Fix infinite spin with pthread_cond_timedwait - #875

Merged
alexcrichton merged 1 commit into
WebAssembly:mainfrom
alexcrichton:fix-pthread-cond-timedwait
Aug 25, 2026
Merged

Fix infinite spin with pthread_cond_timedwait#875
alexcrichton merged 1 commit into
WebAssembly:mainfrom
alexcrichton:fix-pthread-cond-timedwait

Conversation

@alexcrichton

Copy link
Copy Markdown
Collaborator

For non-threaded targets the refactoring in #851 accidentally led this function to spin infinitely instead of trapping as expected.

Closes #874

For non-threaded targets the refactoring in WebAssembly#851 accidentally led this
function to spin infinitely instead of trapping as expected.

Closes WebAssembly#874
@QuantumSegfault

Copy link
Copy Markdown

Yes, this fixes it.

@alexcrichton
alexcrichton requested a review from dicej August 25, 2026 18:29
@QuantumSegfault

Copy link
Copy Markdown

Are other such cases going to be proactively adjusted (compare internal IDs, not the outer pointers)? Or are we just treating this as an exception?

@alexcrichton

Copy link
Copy Markdown
Collaborator Author

I don't personally know the rationale for having these be structures/pointers vs integers like they are on other platforms. To that extent I do not know myself the fallout and consequences of such a decision other than what comes up in issues like this. Basically I would not be confident myself in proactively changing things without having test cases to back things up. Not because I don't want to but because I don't understand enough of the space myself.

If you've got other cases though that don't work or similar I can try to help take a look.

@alexcrichton alexcrichton reopened this Aug 25, 2026
@alexcrichton
alexcrichton enabled auto-merge (squash) August 25, 2026 20:27
@QuantumSegfault

Copy link
Copy Markdown

It's just the one for now.

For context, I ran into this updating DRuntime to wasi-sdk-34

https://github.com/ldc-developers/ldc/pull/5266/changes#diff-4759bb61e58f07d4be780d9105b5d3bdd193703a1915770e3a9f7a931b7bb387

https://github.com/QuantumSegfault/ldc/blob/7489e89947cb78f8d75f07fe55b8667655eb20f7/runtime/druntime/src/core/sync/event.d


Ultimately, it is not a blocker for us because we have to work around the subsequent trap anyway.

@alexcrichton
alexcrichton merged commit e1655e8 into WebAssembly:main Aug 25, 2026
72 checks passed
@alexcrichton
alexcrichton deleted the fix-pthread-cond-timedwait branch August 25, 2026 20:35
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.

pthread_cond_timedwait deadlocks on single-threaded (e.g. WASIp2)

3 participants