Add missing trait implementations for ScopedJoinHandle by Rosdf · Pull Request #136912 · rust-lang/rust (original) (raw)

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

Rosdf

@Rosdf

@Rosdf

@rustbot

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

@rustbot rustbot added O-unix

Operating system: Unix-like

O-windows

Operating system: Windows

S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Feb 12, 2025

@Mark-Simulacrum Mark-Simulacrum added needs-fcp

This change is insta-stable, so needs a completed FCP to proceed.

S-waiting-on-team

Status: Awaiting decision from the relevant subteam (see the T- label).

T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Mar 1, 2025

@Mark-Simulacrum

Marking as needs-fcp and waiting on libs-api, since this is insta-stable. ACP approval doesn't suffice for new stable guarantees AFAIK.

I think there might also be a soundness problem with these APIs?

From docs:

This function transfers ownership of the underlying pthread_t to the caller. Callers are then the unique owners of the pthread_t and must either detach or join the pthread_t once it’s no longer needed.

AFAICT, the implementation of into_inner drops the Packet, decrementing the running threads, which would make the new API unsound in combination with the existing surface area. So I don't think we can provide safe ownership-consuming functions unless they poison the scope or otherwise provide some facility for ensuring it doesn't treat the thread as ended when it hasn't been.

(Ideally we might want to add a Drop impl -- I think that would prevent moving out of a field like this PR does; and/or make into_inner unsafe).

@Rosdf

maybe we can split this trait in two parts, like it is done for windows

@joshtriplett

We discussed this in today's @rust-lang/libs-api meeting. We agreed that all the impls that call into_inner() should not be provided, for the reason @Mark-Simulacrum raised. The traits that only provide as functions are fine.

That would be a blocker for JoinHandleExt, since it has both functions in one trait. There's no problem providing a different extension trait that only provides as_pthread_t, though.

(If that trait were sealed, we could split it in the standard library. But since it isn't sealed, we'd need a separate extension trait.)

@Amanieu

@rustbot rustbot added the S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

label

Apr 1, 2025

@rustbot

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Labels

needs-fcp

This change is insta-stable, so needs a completed FCP to proceed.

O-unix

Operating system: Unix-like

O-windows

Operating system: Windows

S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.