Skip to content

Add missing trait implementations for ScopedJoinHandle #136912

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 and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Rosdf
Copy link

@Rosdf Rosdf commented Feb 12, 2025

@rustbot
Copy link
Collaborator

rustbot commented Feb 12, 2025

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 author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@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-<team> 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
Copy link
Member

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
Copy link
Author

Rosdf commented Mar 18, 2025

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

@joshtriplett
Copy link
Member

joshtriplett commented Mar 25, 2025

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
Copy link
Member

Amanieu commented Apr 1, 2025

@rustbot author

@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
Copy link
Collaborator

rustbot commented Apr 1, 2025

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

@Amanieu Amanieu removed the S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). label Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants