-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Tracking Issue for backtrace_frames
#79676
Comments
@rustbot modify labels +T-libs |
Error: Label B-unstable can only be set by Rust team members Please let |
Apologies if I'm late to the party, or if all of this was discussed before, but I'd suggest studying the C++ stacktrace proposal (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0881r7.html) before stabilizing things like this. The interface is based on Boost.Stacktrace and was heavily scrutinized and changed in non-obvious ways to accommodate for some backtrace operations being expensive or platform-dependent. |
@petrochenkov Looking through the linked document, I don't really see anything that is within scope of this PR. Please let me know if there's any specific points in the doc that should be brought up though; I certainly might have missed something. |
The |
I have just looked at the Backtrace stabilisation announcement in 1.65. However, I wonder, what's the use of it if we can't traverse the frames? I believe the primary use of a stack trace like that would be the possibility to walk over the frames and be able to analyse them in any manner rather than just printing. For example, I'd think of having something like this: https://docs.oracle.com/javase/7/docs/api/java/lang/StackTraceElement.html |
I see this issue has been in progress for over two years now. Here's a use case. I have a GUI program, a metaverse client. One of those things for end users who are not programmers. There's no text console. There are multiple threads. If a thread panics, I need to capture a backtrace, log it, tell the user something via a GUI dialog, and shut down the program. The only thing you can do with a Backtrace right now is format it. You can't iterate over it in production code. Can't even clone it. If you format it, 80% of the output is the panic and backtrace system doing its thing.. I'd like to have both the ability to iterate over a backtrace, and something that extracts only the frames relevant to the cause of the panic. In the playground linked here, the only two relevant lines, out of 30, are:
Everything else is the panic and backtrace system's own machinery. And the included URLs are useless unless you're in a development environment. None of this stuff is oriented towards reporting problems detected in the field. Could be worse. What you get from catch_unwind is an Any that can't even be formatted. |
I've been thinking about reducing the backtrace length as well. It would be great if we could use something like
You can actually convert the value into a |
Yes, reducing the backtrace length to the relevant content would help considerably. Use case: for emergency dialogs, there's rfd::MessageDialog. This will usually work even if the main GUI has panicked. That dialog box doesn't scroll, so the text length has to be limited to 10-20 lines at most. |
I hope I'm not too late to the party, and I want to express few issues that I have with current (nightly) state.
I have created PR where I describe my problem better, and propose very simple solution, but for std;;backtrace I think we need better design. I think we need to address few problems:
With all that said, here are some thoughts:
|
Yes, although that's not intolerable for handing an error just before final exit.
Please don't over-complicate this or spend years bikeshedding. This is part of an emergency abort, not an introspection system. GUI programs, programs which automatically submit crash reports, and programs with no text console need this to report panics. Thanks. |
I wouldn't assume how and why it would be used. As long as something exists, one may never guess how one want to use it. For example, there was an "error-chain" crate that also used the stack traces for each "Error" it created. If it were to be called and printed (let's say, logged) within a loop, it would be a disaster. Not to mention that I fail to see any reason not to look for a possible speed-up for the traversal of the entries and their resolution. If it can be speed up with some effort, it should always be done, it should be proven otherwise - why not to do it. |
I don't want to bikeshed as well, I just wanted to say that |
Looking forward to the stabilization of this feature! My use case is similar to @John-Nagle - I'm building a GUI for non-programmers and want sensible crash reporting. I agree that "reducing the backtrace length to the relevant content would help considerably." |
Four year anniversary of this issue. |
I would also be interested in a method to shorten or filter the backtrace to improve user experience. I am going to use the regex approach mentioned above to solve this in the short-term. In addition, it would help if the API exposed the Both are solvable through regular expressions, but something more robust in Rust would be greatly appreciated in the future. I am writing a decompiler in Rust, and as part of that project, errors and their respective backtraces are serialized, stored in a database, and later analyzed to track progress and bug fixes over time. |
This is a tracking issue for one of the features mentioned in #81022, the ability to create an iterator over backtrace frames.
The feature gate for the issue is
#![feature(backtrace_frames)]
.About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
Backtrace
typeUnresolved Questions
Clone
on theBacktrace
type so as not to expose a publicBacktrace::clone
method. Private clone methods are implemented instead. Is this the long-term API we'll want to stick with?FromIterator
implementation a bit more, because we can't mark trait implementations as unstable so if we added one toBacktrace
we'd be committing to it right away.Implementation history
frames
method on theBacktrace
type that returns aVec<BacktraceFrame>
that can be iterated over.The text was updated successfully, but these errors were encountered: