-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Introduce sys_common::rt::rtprintpanic!
to replace sys_common::util
functionality
#84697
Conversation
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
library/std/src/sys_common/rt.rs
Outdated
@@ -38,8 +39,21 @@ pub fn cleanup() { | |||
}); | |||
} | |||
|
|||
macro_rules! rterr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name could be something different, rtwrite
, rtprint
, rtoutput
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something with print
in the name would be better. err
might suggest it returns from the function or panics or aborts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rtprintpanic!
? I think I'll also add a comment about that this writes to the designated "panic output", which is just stderr
on most platforms.
library/std/src/panicking.rs
Outdated
@@ -571,7 +571,7 @@ fn rust_panic_with_hook( | |||
// process real quickly as we don't want to try calling it again as it'll | |||
// probably just panic again. | |||
if panics > 2 { | |||
util::dumb_print(format_args!("thread panicked while processing panic. aborting.\n")); | |||
rterr!("thread panicked while processing panic. aborting.\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason why here in panicking
intrinsics::abort
is used instead of sys::abort_internal
? Otherwise this could also be written with rtabort!
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sys::abort_internal
calls libc::abort()
(at least on unix). intrinsics::abort
does not rely on libc or the platform, but simply results in executing an invalid instruction. I don't know if there's a reason to avoid libc::abort() here. It'd require some digging through the git history to see if this was changed on purpose, or added before the alternative existed, or something like that. :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked through the history, these intrinsics::abort
were indeed added before sys::abort_internal
existed. As far as I can tell these could be replaced, along with a safety comment added to abort_internal
that it's implementation is not allowed to panic (else panicking is stuck in a loop). However there are more occurrences of intrinsics::abort
in std
that in my opinion could also be replaced, so I think I'm leaving it like this for now and will address those together in a future PR.
sys_common::rt::rterr
to replace sys_common::util
functionalitysys_common::rt::rterr!
to replace sys_common::util
functionality
Ready for another look, only changed the name from |
sys_common::rt::rterr!
to replace sys_common::util
functionalitysys_common::rt::rtprintpanic!
to replace sys_common::util
functionality
☔ The latest upstream changes (presumably #81858) made this pull request unmergeable. Please resolve the merge conflicts. |
I have some Opinions about |
See #85377. |
@CDirkx Thanks again! This looks good to me. Can you rebase it to include the new abort message in |
Rebased 👍🏻 |
Thanks! @bors r+ |
📌 Commit 4ff5ab5 has been approved by |
Introduce `sys_common::rt::rtprintpanic!` to replace `sys_common::util` functionality This PR introduces a new macro `rtprintpanic!`, similar to `sys_common::util::dumb_print` and uses that macro to replace all `sys_common::util` functionality.
☀️ Test successful - checks-actions |
This PR introduces a new macro
rtprintpanic!
, similar tosys_common::util::dumb_print
and uses that macro to replace allsys_common::util
functionality.