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

Improve logging of abort #52633

Closed
Thomasdezeeuw opened this issue Jul 22, 2018 · 4 comments
Closed

Improve logging of abort #52633

Thomasdezeeuw opened this issue Jul 22, 2018 · 4 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@Thomasdezeeuw
Copy link
Contributor

While trying to debug #52629, I've hit an abort() condition when an Arc count wrapped around (it was being dropped twice). At least on macOS it causes the following message to be printed when testing:

error: process didn't exit successfully: `/binary/path` (signal: 4, SIGILL: illegal instruction)

To me this doesn't say that the process was aborted, in fact I though this was a problem with the code being generated. Only after running the code with lldb did I find out that this was actually caused by a call to abort.

So my suggestion is to add some minimal logging that the process was aborted, atleast in debug mode. Just a minimal "aborted process" would done. Maybe this needs a RFC, but I though to start small.

P.S: is the printed error message any better on other Oses?

@csmoe csmoe added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 23, 2018
@ehuss
Copy link
Contributor

ehuss commented Jul 23, 2018

P.S: is the printed error message any better on other Oses?

Not really. When calling intrinsics::abort(), the rust process itself doesn't print anything, so the message depends on the calling process to print something. Things like bash will just say "Illegal instruction" (since all it sees is SIGILL). I just ran into this while working on a panic handler. Fortunately it does print a message before going down:

if panics > 2 {
util::dumb_print(format_args!("thread panicked while processing \
panic. aborting.\n"));
unsafe { intrinsics::abort() }
}

but I think "illegal instruction" is confusing. I'm curious why llvm.trap uses the ud2 instruction on x86 instead of calling abort().

@Thomasdezeeuw
Copy link
Contributor Author

This seems to be resolved. Maybe in 1b1bf24? Thanks @ijackson.

@ijackson
Copy link
Contributor

I don't think any of the things I have done have improved this area, yet, unfortunately. And I think the issue is still present (although I don't have a repro).

In #85377 I am trying to improve the docs on std::process::abort vs core::intrinsics::abort (although I seem to have somehow dropped the ball there; I've put it back on my todo list).

I have another branch where I am trying to make things call std::process::abort (ie abort(3)) more but I had trouble with my new tests failing. A related commit is "panic aborts: Use process::abort() not intrinsics::abort() " ijackson@473313f in that branch which changes panic to use std::process::abort instead.

Fom the messages above, Arc calls abort directly. Indeed I see use core::intrinsics::abort; in library/alloc/src/sync.rs. Fixing that is not so easy because Arc is in alloc, so doesn't even have access to std::process::abort.

So, err, sorry, but I think this problem is still outstanding. Some of these things are on my todo list (having apparently fallen out of my file where I keep these things) but I haven't worked on it recently, and I haven't done a survey of all the abort calls.

@Thomasdezeeuw
Copy link
Contributor Author

@ijackson I'm not sure it was you personally, but multiple situations have certainly improved:

The only other abort I can find is in Packet::clone_chan in

, which is a bit difficult to hit (cloning the channel isize::MAX times).

You're changes in #85377 do seem like a good addition. But I think this issue is correctly closed, maybe another more specific issue can be opened for discouraging use of intrinsics::abort in favour of rocess::abort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

4 participants