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

format panic message only once #110721

Merged
merged 1 commit into from
Apr 28, 2023
Merged

format panic message only once #110721

merged 1 commit into from
Apr 28, 2023

Conversation

lukas-code
Copy link
Member

@lukas-code lukas-code commented Apr 23, 2023

Formatting the panic message multiple times can cause problems for some real-world crates, so here's a test to ensure that we don't do that.

This was regressed in #109507 and reverted in #110782.

fixes #110717
fixes rust-itertools/itertools#694

@rustbot
Copy link
Collaborator

rustbot commented Apr 23, 2023

r? @compiler-errors

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 23, 2023
@rustbot
Copy link
Collaborator

rustbot commented Apr 23, 2023

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

@Amanieu
Copy link
Member

Amanieu commented Apr 23, 2023

This has the unfortunate limitation of forcing an allocation in the panic path even when one isn't necessary (e.g. when using panic=abort). That was one of the main reasons why I made this change, I didn't expect it to break anything. However I think it is fine to revert to the old behavior if this breaks code in practice.

@Amanieu
Copy link
Member

Amanieu commented Apr 23, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Apr 23, 2023

📌 Commit 7410960 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 Apr 23, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 24, 2023
format panic message only once

For `panic!` and friends, the `std` panic runtime will always set the `.payload()` of `PanicInfo` to the formatted string. The linked issues show that formatting the message twice can cause problems, so we simply print the already formatted message instead of formatting it again. We can't remove the preformatted payload, because it can be observed by custom panic hooks.

fixes rust-lang#110717
fixes rust-itertools/itertools#694

cc `@Amanieu` who broke this in rust-lang#109507
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 24, 2023
format panic message only once

For `panic!` and friends, the `std` panic runtime will always set the `.payload()` of `PanicInfo` to the formatted string. The linked issues show that formatting the message twice can cause problems, so we simply print the already formatted message instead of formatting it again. We can't remove the preformatted payload, because it can be observed by custom panic hooks.

fixes rust-lang#110717
fixes rust-itertools/itertools#694

cc ``@Amanieu`` who broke this in rust-lang#109507
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 24, 2023
format panic message only once

For `panic!` and friends, the `std` panic runtime will always set the `.payload()` of `PanicInfo` to the formatted string. The linked issues show that formatting the message twice can cause problems, so we simply print the already formatted message instead of formatting it again. We can't remove the preformatted payload, because it can be observed by custom panic hooks.

fixes rust-lang#110717
fixes rust-itertools/itertools#694

cc ```@Amanieu``` who broke this in rust-lang#109507
@bors
Copy link
Contributor

bors commented Apr 25, 2023

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

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 25, 2023
@Amanieu
Copy link
Member

Amanieu commented Apr 25, 2023

The panic changes have been reverted, but it's still good to have this test.

@bors r+

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 25, 2023
@bors
Copy link
Contributor

bors commented Apr 25, 2023

⌛ Testing commit cd398a6 with merge c61a497df072444f1e66487f5d409d142728bdc0...

@rust-log-analyzer
Copy link
Collaborator

The job dist-aarch64-apple failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling rustc_codegen_llvm v0.0.0 (/Users/runner/work/rust/rust/compiler/rustc_codegen_llvm)
[RUSTC-TIMING] rustc_incremental test:false 39.794
   Compiling rustc_resolve v0.0.0 (/Users/runner/work/rust/rust/compiler/rustc_resolve)
[RUSTC-TIMING] rustc_mir_dataflow test:false 47.278
rustc exited with signal: 11 (SIGSEGV)

Caused by:
Caused by:
  process didn't exit successfully: `/Users/runner/work/rust/rust/build/bootstrap/debug/rustc --crate-name rustc_mir_dataflow --edition=2021 compiler/rustc_mir_dataflow/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -Zunstable-options --check-cfg 'values(feature)' --check-cfg 'names()' --check-cfg 'values()' -C metadata=dc45f0b99d9585f5 -C extra-filename=-dc45f0b99d9585f5 --out-dir /Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps --target x86_64-apple-darwin -L dependency=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps -L dependency=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/release/deps --extern polonius_engine=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/libpolonius_engine-e1bdbea55fe599f0.rmeta --extern regex=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/libregex-a3fd5e0338dab51f.rmeta --extern rustc_ast=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_ast-95330d8e8538a24b.rmeta --extern rustc_data_structures=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_data_structures-4b7c57298ff21b83.rmeta --extern rustc_errors=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_errors-0733e3585f5e071b.rmeta --extern rustc_fluent_macro=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/release/deps/librustc_fluent_macro-7bc1ca42e5aab8e1.dylib --extern rustc_graphviz=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_graphviz-256024e6a3a47524.rmeta --extern rustc_hir=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_hir-51f004634f24b663.rmeta --extern rustc_index=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_index-62e63d6ecd0b6aeb.rmeta --extern rustc_macros=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/release/deps/librustc_macros-e7c8b4e580efcf9c.dylib --extern rustc_middle=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_middle-640ab8b93a877269.rmeta --extern rustc_serialize=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_serialize-b0014741451808d1.rmeta --extern rustc_span=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_span-2ec3c272543211ed.rmeta --extern rustc_target=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_target-0e2ca81239403e31.rmeta --extern smallvec=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/libsmallvec-ea6ce5fe76ae98c3.rmeta --extern tracing=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/libtracing-99fd66853b2d119d.rmeta --cfg=bootstrap --cfg=windows_raw_dylib -Csymbol-mangling-version=v0 -Zunstable-options '--check-cfg=values(bootstrap)' '--check-cfg=values(parallel_compiler)' '--check-cfg=values(no_btreemap_remove_entry)' '--check-cfg=values(crossbeam_loom)' '--check-cfg=values(span_locations)' '--check-cfg=values(rustix_use_libc)' '--check-cfg=values(emulate_second_only_system)' '--check-cfg=values(windows_raw_dylib)' -Zmacro-backtrace -Zosx-rpath-install-name '-Clink-args=-Wl,-rpath,@loader_path/../lib' -Csplit-debuginfo=unpacked -Zunstable-options '-Wrustc::internal' -Cprefer-dynamic -Z binary-dep-depinfo -L native=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/build/psm-cde397fd7aaf5a1d/out` (exit status: 254)
[RUSTC-TIMING] rustc_ast_lowering test:false 63.391
[RUSTC-TIMING] rustc_codegen_ssa test:false 92.051
[RUSTC-TIMING] rustc_infer test:false 109.094
[RUSTC-TIMING] rustc_query_impl test:false 125.993
[RUSTC-TIMING] rustc_query_impl test:false 125.993
rustc exited with signal: 11 (SIGSEGV)

Caused by:
Caused by:
  process didn't exit successfully: `/Users/runner/work/rust/rust/build/bootstrap/debug/rustc --crate-name rustc_query_impl --edition=2021 compiler/rustc_query_impl/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -Zunstable-options --check-cfg 'values(feature, "rustc-rayon-core", "rustc_use_parallel_compiler")' --check-cfg 'names()' --check-cfg 'values()' -C metadata=71f41832f536d702 -C extra-filename=-71f41832f536d702 --out-dir /Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps --target x86_64-apple-darwin -L dependency=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps -L dependency=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/release/deps --extern measureme=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/libmeasureme-ff2ccd485d67efd4.rmeta --extern rustc_ast=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_ast-95330d8e8538a24b.rmeta --extern rustc_data_structures=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_data_structures-4b7c57298ff21b83.rmeta --extern rustc_errors=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_errors-0733e3585f5e071b.rmeta --extern rustc_hir=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_hir-51f004634f24b663.rmeta --extern rustc_index=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_index-62e63d6ecd0b6aeb.rmeta --extern rustc_macros=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/release/deps/librustc_macros-e7c8b4e580efcf9c.dylib --extern rustc_middle=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_middle-640ab8b93a877269.rmeta --extern rustc_query_system=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_query_system-bb20719c6bb7584a.rmeta --extern rustc_serialize=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_serialize-b0014741451808d1.rmeta --extern rustc_session=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_session-1956be589be28ce5.rmeta --extern rustc_span=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/librustc_span-2ec3c272543211ed.rmeta --extern thin_vec=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/libthin_vec-0b56a69de23beef2.rmeta --extern tracing=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/deps/libtracing-99fd66853b2d119d.rmeta --cfg=bootstrap --cfg=windows_raw_dylib -Csymbol-mangling-version=v0 -Zunstable-options '--check-cfg=values(bootstrap)' '--check-cfg=values(parallel_compiler)' '--check-cfg=values(no_btreemap_remove_entry)' '--check-cfg=values(crossbeam_loom)' '--check-cfg=values(span_locations)' '--check-cfg=values(rustix_use_libc)' '--check-cfg=values(emulate_second_only_system)' '--check-cfg=values(windows_raw_dylib)' -Zmacro-backtrace -Zosx-rpath-install-name '-Clink-args=-Wl,-rpath,@loader_path/../lib' -Csplit-debuginfo=unpacked -Zunstable-options '-Wrustc::internal' -Cprefer-dynamic -Z binary-dep-depinfo -L native=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage0-rustc/x86_64-apple-darwin/release/build/psm-cde397fd7aaf5a1d/out` (exit status: 254)
[RUSTC-TIMING] rustc_metadata test:false 135.165
[RUSTC-TIMING] rustc_resolve test:false 102.002
[RUSTC-TIMING] rustc_middle test:false 209.285
[RUSTC-TIMING] rustc_trait_selection test:false 117.423

@bors
Copy link
Contributor

bors commented Apr 25, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 25, 2023
@jyn514 jyn514 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 26, 2023
@Amanieu
Copy link
Member

Amanieu commented Apr 26, 2023

Failure seems unrelated.

@bors retry

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 26, 2023
@bors
Copy link
Contributor

bors commented Apr 26, 2023

⌛ Testing commit cd398a6 with merge 1938114e1de4ff6bb282ed61c1005776b9645202...

@rust-log-analyzer
Copy link
Collaborator

The job dist-mips64el-linux failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented Apr 26, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 26, 2023
@lukas-code
Copy link
Member Author

looks spurious again: "failed to get successful HTTP response from https://crates.io/api/v1/crates/strsim/0.10.0/download, got 503"

@Amanieu
Copy link
Member

Amanieu commented Apr 27, 2023

@bors retry

@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 Apr 27, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 28, 2023
Rollup of 7 pull requests

Successful merges:

 - rust-lang#109702 (configure --set support list as arguments)
 - rust-lang#110620 (Document `const {}` syntax for `std::thread_local`.)
 - rust-lang#110721 (format panic message only once)
 - rust-lang#110881 (refactor(docs): remove macro resolution fallback)
 - rust-lang#110893 (remove inline const deadcode in typeck)
 - rust-lang#110898 (Remove unused std::sys_common::thread_local_key::Key)
 - rust-lang#110909 (Skip `rustc` version detection on macOS)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit eea5f8a into rust-lang:master Apr 28, 2023
@rustbot rustbot added this to the 1.71.0 milestone Apr 28, 2023
@lukas-code lukas-code deleted the panic-fmt branch April 28, 2023 10:02
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
7 participants