Skip to content

Mark Arc function get_mut and method make_unique unsafe #25908

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

Merged
merged 1 commit into from
May 31, 2015

Conversation

bluss
Copy link
Member

@bluss bluss commented May 30, 2015

Mark Arc function get_mut and method make_unique unsafe

This is a temporary mitigation for issue #24880 which points out that
these functions are racy in a particular situation where weak pointers
exist.

To mitigate this, mark the functions unsafe until this can be fixed or
another decision is made.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @huonw (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@bluss
Copy link
Member Author

bluss commented May 30, 2015

I don't want us to sit around with thread unsafe API. I'm sorry I don't know how to fix this, but I can mark it unsafe.

Other options:

  • Outright removal until resolved
  • If we remove Weak support (or make it optional), weakless Arc can offer it.

This is a temporary mitigation for issue rust-lang#24880 which points out that
these functions are racy in a particular situation where weak pointers
exist.

To mitigate this, mark the functions unsafe until this can be fixed or
another decision is made.

This is a breaking change to unstable API, because the new version
requires an `unsafe` block. Review carefully if weak pointers may race
for any uses of this API and consider abandoning it.

[breaking-change]
@bluss bluss force-pushed the arc-mark-unsafe branch from 3410204 to 32211e1 Compare May 30, 2015 20:16
@sfackler
Copy link
Member

I don't think stabilizing these as unsafe functions is a good idea, but this seems like a reasonable path forward in the short term since users will at least be aware of what to be careful of.

@Gankra
Copy link
Contributor

Gankra commented May 31, 2015

Yeah, this is an "honest" adjustment for now.

@bors r+

@bors
Copy link
Collaborator

bors commented May 31, 2015

📌 Commit 32211e1 has been approved by Gankro

@alexcrichton
Copy link
Member

I would also be fine just removing these functions, it's not clear that an implementation is acceptable in terms of performance costs and it's not very useful to have a racy version today.

@bluss
Copy link
Member Author

bluss commented May 31, 2015

@alexcrichton I'm fine either way. It is possible to use these safely for a user who knows they don't use Weak pointers though.

@Gankra
Copy link
Contributor

Gankra commented May 31, 2015

@bors r- (I'm not too strong-willed on this)

@alexcrichton
Copy link
Member

Oh sorry, to clarify I didn't mean to stop this or anything, just saying if you want to amend to remove the functions outright I would also r+ :)

@bluss
Copy link
Member Author

bluss commented May 31, 2015

I just want to go for it. With this change we are back to “honest” so then we're fine to fix it later.

@sfackler
Copy link
Member

@bors r+ 32211e1

bors added a commit that referenced this pull request May 31, 2015
Mark Arc function get_mut and method make_unique unsafe

This is a temporary mitigation for issue #24880 which points out that
these functions are racy in a particular situation where weak pointers
exist.

To mitigate this, mark the functions unsafe until this can be fixed or
another decision is made.
@bors
Copy link
Collaborator

bors commented May 31, 2015

⌛ Testing commit 32211e1 with merge 845cee4...

@bors bors merged commit 32211e1 into rust-lang:master May 31, 2015
@bluss bluss deleted the arc-mark-unsafe branch May 31, 2015 21:41
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.

7 participants