-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Tracking issue for mem::unreachable
#43751
Comments
Bikeshed: I find it surprising that safe |
Another possible name/location for discussion: |
This does not belong in Why not just call it |
There's a suggestion calling it |
I like @notriddle's suggestion. Does what it says on the tin. |
(Sorry, couldn't help myself) |
Except that, in most cases, it won't consume your clothes. Your computer probably doesn't even have the necessary hardware to do anything to your laundry. Undefined behaviour may eat your laundry, because it may do anything; the specification places no constraints on what the result of invoking this intrinsic is. A name like Unlike |
@notriddle Yep, I agree that (Context for those who came to this community after Rust 1.0: Before 1.0 there was a disclaimer on Rust's homepage saying something like it wasn't production ready yet, and could in theory do anything, including eating your laundry. I don't remember the exact wording.) |
I would say |
@earthengine |
Then make it inside |
Consider that another intrinsic, |
I propose that we simply stabilise the This would need some thinking on how to deal with the currently stable intrinsics in there:
|
Would (I thought about calling it |
For the currently-stable things in |
Although they are "stable" they cannot be used as such because importing
the intrinsics module trips the instability check – so a deprecation
doesn't seem necessary to me. At least some of them were made stable as an
implementation detail.
…On Aug 27, 2017 1:15 AM, "scottmcm" ***@***.***> wrote:
For the currently-stable things in intrinsics: Since they're all exported
elsewhere with (nearly?) identical signatures, just deprecate them with a
message suggesting the ptr or mem ones instead?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#43751 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AApc0mwJl8q9HWNO03KHl1ymOItRg7FDks5scJj1gaJpZM4OxZfV>
.
|
It doesn't actually trip the stability check, you can import them from intrinsics if you want even though they are re-exported elsewhere. So we could avoid creating another module. |
Do likely/unlikely also belong in the same category, that category that doesn't have a home in a current submodule? likely/unlikely: #26179 |
|
( |
|
I agree. Especially since their impact for being used incorrectly is simply UB. |
|
Or that means |
I'm actually kinda okay with |
After some discussion on IRC and re-reading the earlier discussion, I actually don't see any reason to not stabilize |
I think it is the opposite, right? If one uses |
I think that something that has |
@SimonSapin I feel like that would make me never use |
You are welcome to use or not use whatever APIs you want. |
I mean, it's supposed to have a deterrent effect, as it should only be used
in really provably unreachable code, so... yeah.
…On Wed, Apr 18, 2018 at 12:35 PM, Steven Fackler ***@***.***> wrote:
You are welcome to use or not use whatever APIs you want.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#43751 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n0dKOv8TqshD52G17jRIeP_OEzz4ks5tp2tQgaJpZM4OxZfV>
.
|
@mark-i-m Double negation is hard and I can’t tell what your "that" refers to. |
To clarify, what I mean is this: I generally prefer to leave asserts on in production, but there are a few asserts that I like to turn off in production. For those few asserts, I still want them on when I'm debugging. I consider While I'm debugging, if I don't want to risk UB. When I deploy, I'm confident enough that I'm willing to not have the assert. If I can't make that distinction cleanly, I'm unlike to ever use |
It sounds like you want to use https://crates.io/crates/debug_unreachable, and maybe there’s a case to be made to include it in the standard library but it shouldn’t be under the name |
… however just copying that code into libstd or libcore probably won’t work since the standard library is always compiled in release mode. |
@SimonSapin That's fair. Thanks :) |
I think @mark-i-m has raised a great point and we need to be more clear about what use cases we envision for
I sympathize with this and I struggle to think of reasonable use cases where I would prefer the current unconditionally unchecked unreachable over something like debug_unreachable. @SimonSapin or @sfackler do you have such a use case in mind? |
How would that be implemented? |
Possibly the same way |
We can do literally anything we want when undefined behavior happens so that's not a thing we need to explicitly guarantee. #45920 causes a trap to be generated from unreachable anyway, so you're already going to abort if an unreachable_unchecked is reached. |
Then it's just a difference between "unconditionally unchecked is the correct behavior for a function with this name, and if we want a debug checked version later we call it something else or recommend a thirdparty crate" vs "we wish we could check in debug mode but the standard library is not set up to be able to do that -- maybe later." You and Simon seem to have been supporting the former but maybe mark-i-m and I would prefer the latter. Is the trap as easily debuggable as a panic with stacktrace? |
Abort doesn't print a stack trace but I believe you can catch it in a
debugger.
…On Wed, Apr 18, 2018 at 4:14 PM, David Tolnay ***@***.***> wrote:
Then it's just a difference between "unconditionally unchecked is the
correct behavior for a function with this name, and if we want a debug
checked version later we call it something else or recommend a thirdparty
crate" vs "we wish we could check in debug mode but the standard library is
not set up to be able to do that -- maybe later." You and Simon seem to
have been supporting the former but maybe mark-i-m and I would prefer the
latter.
Is the trap as easily debuggable as a panic with stacktrace?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#43751 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n_tCywRhtTIgSv7qKr2b20Z3_YIAks5tp56RgaJpZM4OxZfV>
.
|
Note that #45920 only kicks in at codegen time, optimizations based on the UB can still cause arbitrarily bad or confusing consequences. You might not even ever hit the unreachable -- if it is conditional, for example, the branch with the "unreachable" in it might be eliminated entirely. |
One reason for not panicking specifically is that it unwinds the stack, and the surrounding unsafe code might not be equipped to handle that. What if it immediately aborted and printed a stack trace in debug mode? |
It's not quite as nice. A trap will cause the program to be killed on a standard Linux setup. If you are running in GDB, then GDB will pause and you can use
I think I would be ok with pretty much anything, as long as the program halts and some debugging info is printed. |
Well if it's defined to trap it's not undefined, is it? And those "clever
UB optimizations" shouldn't happen in debug mode.
…On Wed, Apr 18, 2018 at 4:25 PM, Robin Kruppe ***@***.***> wrote:
Note that #45920 <#45920> only
kicks in at codegen time, optimizations based on the UB can still cause
arbitrarily bad or confusing consequences. You might not even ever hit the
unreachable -- if it is conditional, for example, the branch with the
"unreachable" in it might be eliminated entirely.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#43751 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC3n89B_KPoilfOw6CqLzu442ctFS97ks5tp6EjgaJpZM4OxZfV>
.
|
I think that I was wrong, and that However I think that for the past three years the crate also hasn’t been doing what everyone thinks it’s doing, since it uses |
|
It's undefined, period, codegen can just be configured is slightly mitigating the impact of any |
Yes but the call site is in libcore, which has already been compiled, so it won't do what you expect. That's why there are |
Undefined doesn't necessarily have to mean unpredictable. Technically, |
This is not true anymore if you factor compilers into the equation. Actual real-world programs don't segfault reliably when the programmer might think that it'd reliably execute the |
Stabilize `std::hint::unreachable_unchecked`. Closes rust-lang#43751.
No description provided.
The text was updated successfully, but these errors were encountered: