Skip to content

Avoid joining threads on exit#3388

Merged
zcbenz merged 1 commit intoml-explore:mainfrom
zcbenz:fix-windows-tests
Apr 11, 2026
Merged

Avoid joining threads on exit#3388
zcbenz merged 1 commit intoml-explore:mainfrom
zcbenz:fix-windows-tests

Conversation

@zcbenz
Copy link
Copy Markdown
Collaborator

@zcbenz zcbenz commented Apr 9, 2026

On Windows there is a bug that joining threads on exit would end up with deadlock, and we can't just leak the threads in CommandEncoder because they are thread local and it would be real leaks.

So instead of joining the threads in the destructor, we detach the threads and let them delete themselves once the threads finish working.

@zcbenz zcbenz force-pushed the fix-windows-tests branch 4 times, most recently from 7ea314a to 3ae07b6 Compare April 10, 2026 06:06
@zcbenz zcbenz force-pushed the fix-windows-tests branch from 3ae07b6 to 33c8ba0 Compare April 10, 2026 06:34
Copy link
Copy Markdown
Member

@angeloskath angeloskath left a comment

Choose a reason for hiding this comment

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

Looks great, left a tiny comment.

#include <mutex>
#include <stdexcept>
#include <string>
#include <thread>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Forgotten?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This file implicitly included the thread via device.h => worker.h, which this PR removes from device.h's includes.

@zcbenz zcbenz merged commit 520cea2 into ml-explore:main Apr 11, 2026
16 checks passed
@zcbenz zcbenz deleted the fix-windows-tests branch April 11, 2026 00:22
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.

2 participants