Skip to content

Document Poisoning in LazyCell and LazyLock #144872

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 3 commits into
base: master
Choose a base branch
from

Conversation

connortsui20
Copy link
Contributor

@connortsui20 connortsui20 commented Aug 3, 2025

Currently, there is no documentation of poisoning behavior in either LazyCell or LazyLock, even though both of them can be observed as poisoned by users.

LazyCell plagyround example

LazyLock playground example

Open Questions

  • Is it worth making the implementation of LazyLock more complicated to ensure that the the panic message is "LazyLock instance has previously been poisoned" instead of "Once instance has previously been poisoned"? See the LazyLock playground link above for more context.
  • Does it make sense to move LazyLock into the poison module? It is certainly a poison-able type, but at the same time it is slightly different from the 4 other types currently in the poison module in that it is unrecoverable. I think this is more of a libs-api question.

@rustbot label +T-libs-api

Please let me know if these open questions deserve a separate issue / PR!

@rustbot
Copy link
Collaborator

rustbot commented Aug 3, 2025

r? @thomcc

rustbot has assigned @thomcc.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Aug 3, 2025
@connortsui20
Copy link
Contributor Author

Actually r? @Amanieu since you recently reviewed the poisoning documentation PR #144185?

@rustbot rustbot assigned Amanieu and unassigned thomcc Aug 4, 2025
@Amanieu
Copy link
Member

Amanieu commented Aug 4, 2025

  • Is it worth making the implementation of LazyLock more complicated to ensure that the the panic message is "LazyLock instance has previously been poisoned" instead of "Once instance has previously been poisoned"? See the LazyLock playground link above for more context.

I think this is valid since Once is an internal implementation detail of LazyLock: users seeing this panic message will be confused since they don't use Once directly in their code. However this can be done in a separate PR.

  • Does it make sense to move LazyLock into the poison module? It is certainly a poison-able type, but at the same time it is slightly different from the 4 other types currently in the poison module in that it is unrecoverable. I think this is more of a libs-api question.

This should probably be raised as an open question in #134646, which tracks the poison module.

@Amanieu
Copy link
Member

Amanieu commented Aug 4, 2025

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 4, 2025

📌 Commit 96adb7d has been approved by Amanieu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue. 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