Skip to content
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

Allow Arc::from_raw to be used with a pointer from Arc::as_ptr #106185

Closed

Conversation

albertlarsan68
Copy link
Member

@albertlarsan68 albertlarsan68 commented Dec 27, 2022

Closes #106124

r? rust-lang/libs-api

@rustbot labels +A-docs +T-libs-api -T-libs

@rustbot rustbot added 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 Dec 27, 2022
@rustbot
Copy link
Collaborator

rustbot commented Dec 27, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rustbot rustbot added A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 27, 2022
@marmeladema
Copy link
Contributor

marmeladema commented Dec 27, 2022

What happens when an Arc built with a call to Arc::from_raw on a pointer obtained from Arc::as_ptr when it is dropped? Won't that decrement the strong count and potentially free the underlying object even though there are still Arcs alive for that same object?

https://play.rust-lang.org/?version=stable&mode=release&edition=2021&gist=f39f5c227412d4659d6a1edc9c3ac21e

I have always thought strong_count was always >= 1

EDIT: ok that won't free it because the strong count will wrap but then it might lead to leaks which is probably not unsound but a bit tricky to debug.

What's the real gain by allowing this?

@albertlarsan68 albertlarsan68 deleted the doc-arc-from-raw branch January 11, 2023 07:13
@albertlarsan68 albertlarsan68 restored the doc-arc-from-raw branch January 15, 2023 12:31
@anden3 anden3 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 13, 2023
@anden3
Copy link
Contributor

anden3 commented Apr 13, 2023

Hello @albertlarsan68! Has there been any updates since the review posted above?

@bors
Copy link
Contributor

bors commented Jul 18, 2023

☔ The latest upstream changes (presumably #89132) made this pull request unmergeable. Please resolve the merge conflicts.

@Dylan-DPC
Copy link
Member

Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks

@Dylan-DPC Dylan-DPC added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 30, 2023
@Dylan-DPC Dylan-DPC closed this Jul 30, 2023
@albertlarsan68 albertlarsan68 deleted the doc-arc-from-raw branch July 30, 2023 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. 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.

Documentation of Arc::from_raw is unnecessarily restrictive
7 participants