Skip to content

Conversation

connortsui20
Copy link
Contributor

Fixes the issue raised in #144872 (comment)

r? @Amanieu

@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 Aug 12, 2025
@connortsui20 connortsui20 force-pushed the lazylock-poison-msg branch 2 times, most recently from 2aea6c2 to e77c6fc Compare August 12, 2025 12:40
@bors
Copy link
Collaborator

bors commented Aug 19, 2025

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

@rustbot

This comment has been minimized.

@connortsui20
Copy link
Contributor Author

@bjorn3 just a bump on my question in #145307 (comment), do you think it makes sense to add an argument to every implementation's call_once and wait functions for this? It's not a super difficult change, but I'm worried that it will make everything more complicated for what is probably not too much benefit.

Though I might be misunderstanding something: My understanding of the issue here is just that catch_unwind doesn't prevent the first message being printed. Is something else happening as well that is not obvious? I don't fully understand the foreign exception thing either and why that is important.

@bjorn3
Copy link
Member

bjorn3 commented Aug 19, 2025

I don't fully understand the foreign exception thing either and why that is important.

A foreign exception would be for example a C++ exception that unwinds though Rust code. Foreign exceptions can't be safely catched and rethrown. For example for C++ this would require calling a C++ runtime function to link the exception from the list of exceptions and later relink it. We can't do this in Rust as we can't depend on any particular C++ runtime or even any C++ runtime existing at all. For this reason trying to catch a foreign exception currently aborts the entire process.

@rustbot
Copy link
Collaborator

rustbot commented Aug 21, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Fixes an issue where if the underlying `Once` panics because it is
poisoned, the panic displays the wrong message.

Signed-off-by: Connor Tsui <[email protected]>
Comment on lines -148 to -157
#[test]
#[should_panic = "has previously been poisoned"]
fn lazy_force_mut_panic() {
let mut lazy = LazyLock::<String>::new(|| panic!());
panic::catch_unwind(panic::AssertUnwindSafe(|| {
let _ = LazyLock::force_mut(&mut lazy);
}))
.unwrap_err();
let _ = &*lazy;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is moved down and renamed to lazy_deref_mut_panic

@connortsui20 connortsui20 requested review from Amanieu and bjorn3 August 22, 2025 20:22
@Amanieu
Copy link
Member

Amanieu commented Aug 22, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 22, 2025

📌 Commit 06eb782 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 22, 2025
samueltardieu added a commit to samueltardieu/rust that referenced this pull request Aug 23, 2025
…r=Amanieu

Fix `LazyLock` poison panic message

Fixes the issue raised in rust-lang#144872 (comment)

r? `@Amanieu`
bors added a commit that referenced this pull request Aug 23, 2025
Rollup of 7 pull requests

Successful merges:

 - #144452 (std/sys/fd: Relax `READ_LIMIT` on Darwin)
 - #145307 (Fix `LazyLock` poison panic message)
 - #145515 (Optimize `char::encode_utf8`)
 - #145540 (interpret/allocation: get_range on ProvenanceMap)
 - #145774 (Remove default opts from config)
 - #145780 (Do not warn about missing change ID in tarball builds)
 - #145781 (Remove profile section from Clippy)

r? `@ghost`
`@rustbot` modify labels: rollup
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 23, 2025
…r=Amanieu

Fix `LazyLock` poison panic message

Fixes the issue raised in rust-lang#144872 (comment)

r? ``@Amanieu``
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 24, 2025
…r=Amanieu

Fix `LazyLock` poison panic message

Fixes the issue raised in rust-lang#144872 (comment)

r? `@Amanieu`
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 24, 2025
…r=Amanieu

Fix `LazyLock` poison panic message

Fixes the issue raised in rust-lang#144872 (comment)

r? ``@Amanieu``
bors added a commit that referenced this pull request Aug 24, 2025
Rollup of 6 pull requests

Successful merges:

 - #144531 (Add lint against integer to pointer transmutes)
 - #144885 (Implement some more checks in `ptr_guaranteed_cmp`. )
 - #145307 (Fix `LazyLock` poison panic message)
 - #145554 (rustc-dev-guide subtree update)
 - #145798 (Use unnamed lifetime spans as primary spans for `MISMATCHED_LIFETIME_SYNTAXES`)
 - #145799 (std/src/lib.rs: mention "search button" instead of "search bar")

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Aug 24, 2025
Rollup of 5 pull requests

Successful merges:

 - #144531 (Add lint against integer to pointer transmutes)
 - #145307 (Fix `LazyLock` poison panic message)
 - #145554 (rustc-dev-guide subtree update)
 - #145798 (Use unnamed lifetime spans as primary spans for `MISMATCHED_LIFETIME_SYNTAXES`)
 - #145799 (std/src/lib.rs: mention "search button" instead of "search bar")

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d5340c2 into rust-lang:master Aug 24, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 24, 2025
rust-timer added a commit that referenced this pull request Aug 24, 2025
Rollup merge of #145307 - connortsui20:lazylock-poison-msg, r=Amanieu

Fix `LazyLock` poison panic message

Fixes the issue raised in #144872 (comment)

r? ```@Amanieu```
@jhpratt
Copy link
Member

jhpratt commented Aug 24, 2025

still in queue

@bors r-

@bors
Copy link
Collaborator

bors commented Aug 24, 2025

⌛ Testing commit 06eb782 with merge 4eedad3...

@jhpratt
Copy link
Member

jhpratt commented Aug 24, 2025

@bors r- retry

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 24, 2025
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Aug 25, 2025
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#144531 (Add lint against integer to pointer transmutes)
 - rust-lang/rust#145307 (Fix `LazyLock` poison panic message)
 - rust-lang/rust#145554 (rustc-dev-guide subtree update)
 - rust-lang/rust#145798 (Use unnamed lifetime spans as primary spans for `MISMATCHED_LIFETIME_SYNTAXES`)
 - rust-lang/rust#145799 (std/src/lib.rs: mention "search button" instead of "search bar")

r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Aug 25, 2025
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#144531 (Add lint against integer to pointer transmutes)
 - rust-lang/rust#145307 (Fix `LazyLock` poison panic message)
 - rust-lang/rust#145554 (rustc-dev-guide subtree update)
 - rust-lang/rust#145798 (Use unnamed lifetime spans as primary spans for `MISMATCHED_LIFETIME_SYNTAXES`)
 - rust-lang/rust#145799 (std/src/lib.rs: mention "search button" instead of "search bar")

r? `@ghost`
`@rustbot` modify labels: rollup
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants