-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Make ub_check message clear that it's not an assert #136750
Conversation
r? @saethlin |
It's good to have experience reports, but these checks have been around for 6 releases and this is the first time I've seen this response. Everyone else seems clear on the idea that "violating an unsafe precondition" is something you should fix your code to not do. If it's that combination of words that is hard to understand, I'd rather adjust those in the diagnostic than shout at our users or emit text that is redundant to everyone but an extremely small minority. |
I've calmed down the shouty part. The current "unsafe precondition(s) violated" part is very clear that a precondition has been violated, but on its own is not very clear what the consequences of violating the precondition are. It's not obvious whether this check indicates UB, or prevents UB. Compare:
On the surface both safety checks are similar and catch the same error, but they indicate very different things. Evidently, the wording difference between "unsafe precondition" and other preconditions that prevent unsafety isn't clear enough. So I still think the message would benefit from giving more context. This message is only aimed at developers, and is only meant to be used in dev builds, so I don't see a problem with making it as long as needed. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The Miri subtree was changed cc @rust-lang/miri |
Hm. I think I'm more positive on this now, but really my opinion on these tends to change as a result of directly watching people run into them. Thank you for your input on this little feature. @bors r+ rollup |
Make ub_check message clear that it's not an assert I've seen a user assume that their unsound code was *safe*, because ub_check prevented the program from performing the unsafe operation. This PR makes the panic message clearer that ub_check is a bug detector, not run-time safety protection.
Make ub_check message clear that it's not an assert I've seen a user assume that their unsound code was *safe*, because ub_check prevented the program from performing the unsafe operation. This PR makes the panic message clearer that ub_check is a bug detector, not run-time safety protection.
…llaumeGomez Rollup of 11 pull requests Successful merges: - rust-lang#127793 (Added project-specific Zed IDE settings) - rust-lang#134995 (Stabilize const_slice_flatten) - rust-lang#135767 (Future incompatibility warning `unsupported_fn_ptr_calling_conventions`: Also warn in dependencies) - rust-lang#136599 (librustdoc: more usages of `Joined::joined`) - rust-lang#136750 (Make ub_check message clear that it's not an assert) - rust-lang#137000 (Deeply normalize item bounds in new solver) - rust-lang#137126 (fix docs for inherent str constructors) - rust-lang#137151 (Install more signal stack trace handlers) - rust-lang#137161 (Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions) - rust-lang#137167 (tests: Also gate `f16::erfc()` doctest with `reliable_f16_math` cfg) - rust-lang#137177 (Update `minifier-rs` version to `0.3.5`) r? `@ghost` `@rustbot` modify labels: rollup
Make ub_check message clear that it's not an assert I've seen a user assume that their unsound code was *safe*, because ub_check prevented the program from performing the unsafe operation. This PR makes the panic message clearer that ub_check is a bug detector, not run-time safety protection.
Rollup of 9 pull requests Successful merges: - rust-lang#136750 (Make ub_check message clear that it's not an assert) - rust-lang#137151 (Install more signal stack trace handlers) - rust-lang#137167 (tests: Also gate `f16::erfc()` doctest with `reliable_f16_math` cfg) - rust-lang#137195 (cg_clif: use exclusively ABI alignment) - rust-lang#137202 (Enforce T: Hash for Interned<...>) - rust-lang#137205 (Remove `std::os::wasi::fs::FileExt::tell`) - rust-lang#137211 (don't ICE for alias-relate goals with error term) - rust-lang#137214 (add last std diagnostic items for clippy) - rust-lang#137221 (Remove scrutinee_hir_id from ExprKind::Match) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#136750 - kornelski:ub-bug, r=saethlin Make ub_check message clear that it's not an assert I've seen a user assume that their unsound code was *safe*, because ub_check prevented the program from performing the unsafe operation. This PR makes the panic message clearer that ub_check is a bug detector, not run-time safety protection.
I've seen a user assume that their unsound code was safe, because ub_check prevented the program from performing the unsafe operation.
This PR makes the panic message clearer that ub_check is a bug detector, not run-time safety protection.