Does the UXP platform have a facility for generating crash logs that applications can enable? Topic is solved

Discussions about the development and maturation of the platform code (UXP).
Warning: may contain highly-technical topics.

Moderators: trava90, athenian200

User avatar
athenian200
Contributing developer
Contributing developer
Posts: 1478
Joined: 2018-10-28, 19:56
Location: Georgia

Does the UXP platform have a facility for generating crash logs that applications can enable?

Unread post by athenian200 » 2022-07-26, 01:56

So, a user asked me a question recently about functionality related to generating crash logs, and I realized I don't actually know the platform's capabilities on this front.
Baloo wrote:
2022-07-25, 01:01
Is there a way I can export a crash log and send to you athenian200?
I did a little research on this, but the only thing I found was information about the Mozilla crash reporter which was apparently enabled by using --enable-crashreporter. That seems to generate crash reports that are designed for auto-submission, but presumably they could also be intercepted and sent manually. That option isn't used in any .mozconfig I've seen for a UXP application, and enabling it doesn't seem to do much.

The thing is, I've never actually needed a proper crash log or worried about things like this in the entire time I've been working with UXP applications... at most an application would generate some kind of core dump containing a stack trace upon crashing that I could look over, but I've never had to actually rely on the application itself to actually generate a clearly-labeled report internally that a user can submit to me explaining what happened during a crash.

If there is such a functionality, I'm wondering what I would need do to enable it. And if not, I'm curious what is done instead. A user just describing their problem without any solid information about the crash in the form of a stack trace doesn't really seem like it would help me resolve their issue.

I know this is kind of a rookie question, given that this seems like something I should know given how long I've been working with the platform... but I just have not dealt with the gathering info from users part enough to know how this works.
"The Athenians, however, represent the unity of these opposites; in them, mind or spirit has emerged from the Theban subjectivity without losing itself in the Spartan objectivity of ethical life. With the Athenians, the rights of the State and of the individual found as perfect a union as was possible at all at the level of the Greek spirit." -- Hegel's philosophy of Mind

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35402
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Does the UXP platform have a facility for generating crash logs that applications can enable?

Unread post by Moonchild » 2022-07-26, 06:01

We don't have a crash reporter, and actually removed the plumbing for it a long time ago anyway (with vestiges remaining in lace until I removed telemetry plumbing) because there really is no need for detailed a crash log facility to intercept every cycle to see if something is going to crash or not.

The thing we'd mostly just need is a stack trace anyway since that shows exactly the subsequent calls leading up to a crash, will show if the crash was our code or external code, but if more information is necessary then a dump can be used (e.g. in case the contents of variables/arguments are pivotal in understanding what goes wrong). How to capture that depends on the O.S. - I made a write-up how to do it on Windows; i'm assuming on Linux and Solaris it would be similar, just using different tools.
Basically it's the following sequence:
  1. Run the program
  2. While the program is running, start a debugger and attach it to the program's process (another advantage of being single-process shows here ;))
  3. Make the program crash
  4. The debugger will intercept the crash and you can get immediate insight into the crash if on a dev machine, or if this is and end user, there should be an option to save a program dump in its crashing state to disk (these dumps can be large, beware! They tend to include a snapshot of the program's active memory used)
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
athenian200
Contributing developer
Contributing developer
Posts: 1478
Joined: 2018-10-28, 19:56
Location: Georgia

Re: Does the UXP platform have a facility for generating crash logs that applications can enable?

Unread post by athenian200 » 2022-07-26, 11:20

I see, it is good to have a firm answer on this. :)

You're right, this isn't much of a problem on Windows. Visual Studio's debugging tools make it fairly easy to generate complete minidumps, and if you have it installed, it will go to exactly the place in the program code where it crashed. It's one of the reasons why if we have a crash that occurs on multiple platforms, Windows is my preferred choice for debugging. Visual Studio is just that good.

But the situation on Linux is much, much worse. The debugging tools are... primitive by comparison. GDB doesn't really generate minidumps at all. In fact, the few programs that do generate them rely on tools like Google Breakpad to do so. If the program happens to generate a core dump, you can open that up to get a stack trace using pstack (which is much easier than using gdb), but there's no guarantee you will get one depending on the type of crash. Failing that, you have to have GDB hooked up to the program when it crashes, and often you even have to select a breakpoint that enables gdb to stop as soon as the crashing code is reached. It's fully command-line based, the commands are not really intuitive, and it doesn't have a GUI at all AFAIK. GDB is also prone to having the application crash and take the debugger down with it while trying to debug issues, in my experience.

So, this answer if I understand it correctly, means that it is very undesirable to have a crash on Unix because it effectively means a user cannot gather information easily and we're more likely to have to either reproduce the crash ourselves or have the user mess with GDB to give us more information. That is kind of what I thought, but I didn't want to jump to that conclusion if there was something I'd missed.
"The Athenians, however, represent the unity of these opposites; in them, mind or spirit has emerged from the Theban subjectivity without losing itself in the Spartan objectivity of ethical life. With the Athenians, the rights of the State and of the individual found as perfect a union as was possible at all at the level of the Greek spirit." -- Hegel's philosophy of Mind

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35402
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Does the UXP platform have a facility for generating crash logs that applications can enable?

Unread post by Moonchild » 2022-07-26, 13:11

athenian200 wrote:
2022-07-26, 11:20
So, this answer if I understand it correctly, means that it is very undesirable to have a crash on Unix because it effectively means a user cannot gather information easily and we're more likely to have to either reproduce the crash ourselves or have the user mess with GDB to give us more information.
I simply don't have much experience debugging on *nix, and honestly don't really have the desire to feel like I'm struggling with Slackware in the '90s all over again to debug a crash, so I'm unlikely to put effort into learning :P
If the tools are still that primitive then I'm afraid I can't help much. If there are better tools then I'm not aware of them. But seriously, crashes that need that level of detail are very rare (and pretty much limited to the JS engine) so I wouldn't worry too terribly much about it. Having them be *nix-exclusive on top is even rarer.
As far as I understood attaching gdb is fairly simple and if a crash is reproduced it should be able to spit out a callstack.
If you don't like attaching debuggers then I'm afraid there's little alternative option -- it is the way crashes are intercepted, period; and it's just how it's done. For the record, going from a crash report with just an address and finding out where in the code it crashes on Windows is also a bit involved (and requires a debugger, the exact version of the crashing binary, a hex calculator, and some time) but definitely not impossible, even if all symbols are stripped and it doesn't already spit out a function name. I'm pretty sure the same thing can be done on *nix.

By the way, the Mozilla Crashreporter is a hacked version of Google breakpad (is anyone surprised? I'm not)
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
athenian200
Contributing developer
Contributing developer
Posts: 1478
Joined: 2018-10-28, 19:56
Location: Georgia

Re: Does the UXP platform have a facility for generating crash logs that applications can enable?

Unread post by athenian200 » 2022-07-26, 14:32

Well, we're kind of in the same boat, really. Attaching the debugger on Windows to intercept a crash is not very difficult and generates fairly good output immediately with a few simple steps that I can easily explain to users. That's basically as good as a crash log. It probably doesn't help that I am way more comfortable with Windows/Visual Studio in general because that's what I learned to program C++ on in the first place.

I don't mind attaching debuggers for myself, I messed with GDB quite a bit while doing my SunOS port. Though Solaris does have some additional debugging tools Linux doesn't have that can pick up the slack where GDB fails, which is one of the reasons I like it better than Linux. The main difficulty is trying to walk an end user through the process of attaching GDB and generating a stack trace. I feel like most of the users that know how to do that could probably solve their own problems, though.
"The Athenians, however, represent the unity of these opposites; in them, mind or spirit has emerged from the Theban subjectivity without losing itself in the Spartan objectivity of ethical life. With the Athenians, the rights of the State and of the individual found as perfect a union as was possible at all at the level of the Greek spirit." -- Hegel's philosophy of Mind

Locked