Crash and error reports
Pre-release. Available in the Rust SDK, the C interface and the C++, C#, Python and Java wrappers.
Your app can send crash reports, unexpected exits and error reports that users write. The server groups them by exception and top frames, marks a group as a regression when it comes back in a newer version, and shows everything under Crash reports in the dashboard and at /v1/crash-groups in the Management API.
Reports are off by default, twice:
- The product must accept them: turn on Crash reports in the product's settings for the environment (
crash_reports, withcrash_retention_daysfrom 1 to 90, default 90). - Your app must turn them on: nothing is captured or sent until it creates a
CrashReporter. Ask your users before you turn on automatic reports (crashandexit), and offer a way to turn them off: in the EU, reading information from a user's device for diagnostics generally needs consent. A report the user writes and sends (error) needs no extra consent; show that log lines go along. See Asking for consent below, and the text modules for your dialog and privacy notice.
Asking for consent
Automatic reports start with start() (an unclean end of the last run becomes an exit report) and with the hooks (install_panic_hook, install_native_handler and the wrappers' exception handlers). Call them only once the user agreed. Without consent your app can still create the reporter and send reports the user writes (error), because the user sends those on purpose.
- Ask before the first automatic report. Show the consent dialog at first start or in onboarding, before
start(). "Not now" is the default and must be as easy as "Send reports". Do not ask again on every start; once a version is enough. - Store the answer yourself, in your app's settings, with the time it was given. The SDK does not keep it.
- Offer a switch in your settings that turns automatic reports off as easily as they were turned on. Link your privacy notice next to it.
- On "off" call
clear()andfinish(): queued reports and a native crash waiting for the next start are deleted, and the next start reports no unexpected exit. Hooks installed in this run stay until the app ends. Whatever they still catch is deleted byclear()at the next start, as in the example below; if your app sends reports again in the same run, callclear()once more before sending.
use std::sync::Arc;
use sdk_core::CrashReporter;
let reporter = Arc::new(CrashReporter::new(app_data_dir.join("crash-reports"), "1.4.0")?);
if settings.crash_reports_allowed() { // the user's answer, stored by your app
reporter.start()?;
reporter.install_panic_hook();
} else {
reporter.clear()?; // nothing from runs before "off" goes out
}
// Always fine: a report the user writes in "Report a problem".
reporter.report_error("Export fails", Some("Open a file, click Export"), None)?;
// The user turns automatic reports off in your settings.
fn turn_off(reporter: &CrashReporter, settings: &mut Settings) -> std::io::Result<()> {
settings.set_crash_reports_allowed(false);
reporter.clear()?;
reporter.finish()
}
The other languages have the same calls: C lsdk_crash_reporter_clear and lsdk_crash_reporter_finish, C++ clear() and finish(), C# Clear() and Finish(), Python clear() and finish(), Java clear() and finish(). Install the wrappers' exception handlers only after consent, like the panic hook.
In the "Report a problem" dialog, say that the last log lines of the app go along, and make contact optional.
What a report holds
Only what your app hands over:
| Field | Source |
|---|---|
kind |
crash (a panic or a crash your app caught), exit (the previous run did not shut down cleanly), error (a report the user wrote) |
exception, message |
The panic message, or what your app passes. Up to 200 and 2000 characters |
frames |
The stack of a Rust panic or of an exception the wrapper reports, up to 128 frames: function, module, file, line. Wrappers send file names without their folder, so no install path with a user name leaves the device |
log |
The last 100 lines your app passed to log, up to 1000 characters each |
steps, contact |
Only for error: what the user did and how to reach them, if they gave it |
The SDK adds the app version, the platform and, if set, the build digest. It adds no hardware features, no host name and no user name. The server stores no IP address with a report. Never put personal data of your users into log or messages; the error fields are the only place for text the user wrote. Reports are deleted after the product's retention, and with their license when you delete or erase it.
Rust
use std::sync::Arc;
use sdk_core::CrashReporter;
// Once at start, only if the user agreed to send reports.
let reporter = Arc::new(CrashReporter::new(app_data_dir.join("crash-reports"), "1.4.0")?);
let previous_run_crashed = reporter.start()?; // queues an `exit` report for an unclean end
reporter.install_panic_hook(); // panics become `crash` reports
reporter.log("opened project"); // context for the next report
// A report the user wrote, for example from a "Report a problem" dialog.
reporter.report_error("Export fails", Some("Open a file, click Export"), Some("dana@example.com"))?;
// Whenever the app has a network and an activation, for example after `check`.
let sent = client.send_crash_reports(&reporter)?;
// On a clean shutdown, so the next start reports no unexpected exit.
reporter.finish()?;
- Queue. Reports wait as files in the directory you pass, at most 10; the oldest goes first. Pick a directory of your app's own data, one per product and environment.
clear()deletes the queue, for example when the user turns reports off. - Sending.
send_crash_reportssends the oldest first, each with the app version that produced it, so a crash of 1.3.0 counts for 1.3.0 even if it is sent from 1.4.0. It removes a report once the server answered and stops at the first network failure. Reports the server refuses withinvalid_request(for example while the product does not accept reports) are dropped. The call is signed with the activation's device key like every call of an activation. - Limits. The SDK cuts reports to the server's limits (32 KiB). The server takes at most 20 reports per activation and day; it answers further ones without storing them.
- Build.
CrashReporter::with_build(current_build_digest()?)sends the same build digest asClient::with_build. - Native crashes. By default the SDK installs no signal or exception handlers: a segfault or an abort ends the process, and the next
start()notices that the previous run did not callfinish()and queues anexitreport. On Linux, Android, macOS and Windows your app can ask for more withreporter.install_native_handler()(C:lsdk_crash_reporter_install_native_handler, C++:install_native_handler()), afterstart(): handlers forSIGSEGV,SIGBUS,SIGILL,SIGFPEandSIGABRTwrite the signal and the stack's addresses to the queue directory, and the nextstart()queues acrashreport whose frames carry module name, debug ID and offset. Upload the debug symbols of the build and the dashboard shows function, file and line. The handlers set before still run, so the process ends as it would have. Modules loaded after the call are not in the report. On Windows it is a filter for unhandled exceptions instead: the report names the exception, such asEXCEPTION_ACCESS_VIOLATION, and the filter set before runs after it. Do not use it in apps that run in the JVM or .NET, which handle these signals and exceptions themselves. Other platforms answerconfig_invalid. - Uncaught exceptions. A crash the SDK caught on its way out (a panic, or an uncaught exception in a wrapper) marks the run as crashed, so the next
start()queues noexitreport for the same end.
C
lsdk_crash_reporter *reporter = NULL;
lsdk_error *e = lsdk_crash_reporter_new("/path/to/app-data/crash-reports", "1.4.0", NULL, &reporter);
bool unclean = false;
e = lsdk_crash_reporter_start(reporter, &unclean);
lsdk_crash_reporter_log(reporter, "opened project");
lsdk_crash_reporter_report_crash(reporter, "SIGSEGV", "caught in the render thread");
lsdk_crash_reporter_report_error(reporter, "Export fails", "Open a file, click Export", NULL);
size_t sent = 0;
e = lsdk_client_send_crash_reports(client, reporter, &sent);
lsdk_crash_reporter_finish(reporter);
lsdk_crash_reporter_free(reporter);
Every function returns NULL or an lsdk_error to free, as everywhere in the C SDK. lsdk_crash_reporter_pending counts the queue, lsdk_crash_reporter_clear deletes it.
lsdk_crash_reporter_report_exception(reporter, exception, message, frames_json, fatal) is for runtimes that catch their own exceptions: frames_json is NULL or a JSON array of frames with any of function, module, file, line and address, innermost first. With fatal set, the process is about to end, and the next start queues no exit report for this run. The wrappers below use it.
C++
auto reporter = std::make_shared<lsdk::CrashReporter>(app_data_dir + "/crash-reports", "1.4.0");
bool previous_run_crashed = reporter->start();
lsdk::CrashReporter::install_terminate_handler(reporter); // uncaught exceptions become crash reports
reporter->log("opened project");
try {
export_file();
} catch (const std::exception& e) {
reporter->report_exception(e); // type and what()
}
reporter->report_error("Export fails", std::string("Open a file, click Export"));
size_t sent = client.send_crash_reports(*reporter);
reporter->finish();
install_terminate_handler sets a std::terminate handler that queues the exception and then calls the handler set before. C++ exceptions carry no stack, so these reports have type and message only. Errors throw lsdk::Error as in the rest of the C++ SDK.
C#
using var reporter = new CrashReporter(Path.Combine(appDataDir, "crash-reports"), "1.4.0");
bool previousRunCrashed = reporter.Start();
reporter.InstallUnhandledExceptionHandler(); // AppDomain.UnhandledException
reporter.Log("opened project");
try { ExportFile(); }
catch (IOException e) { reporter.ReportException(e); } // type, message and stack
int sent = await client.SendCrashReportsAsync(reporter);
reporter.Finish();
The handler queues every exception nobody caught; when the runtime ends the process for it, the run counts as crashed. Frames carry the method, the assembly and, with debug information, file name and line. Dispose removes the handler.
Python
from license_sdk import CrashReporter
reporter = CrashReporter(app_data_dir / "crash-reports", "1.4.0")
previous_run_crashed = reporter.start()
reporter.install_excepthook() # sys.excepthook and threading.excepthook
reporter.log("opened project")
try:
export_file()
except OSError as e:
reporter.report_exception(e) # type, message and traceback
sent = client.send_crash_reports(reporter)
reporter.finish()
The hooks queue exceptions nobody caught and then call the hooks set before, so the traceback is still printed. One in the main thread ends the run; one in another thread does not. KeyboardInterrupt is not reported. Frames carry function, module, file name and line. close() restores the earlier hooks.
Java
try (CrashReporter reporter = new CrashReporter(new File(appDataDir, "crash-reports"), "1.4.0")) {
boolean previousRunCrashed = reporter.start();
reporter.installUncaughtExceptionHandler(); // Thread.setDefaultUncaughtExceptionHandler
reporter.log("opened project");
try {
exportFile();
} catch (IOException e) {
reporter.reportException(e); // class, message and stack
}
int sent = client.sendCrashReports(reporter);
reporter.finish();
}
The handler queues exceptions nobody caught in any thread and then calls the handler set before. One in the thread named main counts as the end of the run. close() restores the earlier handler.
In the dashboard and the API
Each group shows its status (new, in progress, resolved, ignored), the assignee, your notes, reports and devices per version, and every report with its frames and log. Copy as issue puts a Markdown summary without message, log or contact into the clipboard for your own tracker. Resolving a group remembers the highest version seen so far; a report from a higher version reopens it as a regression.
Crash rate by version shows, per version over the last 30 days, the devices seen, device-days, crashes and unexpected exits, and crashes per 1,000 device-days compared with the version before (GET /v1/crash-stats). Devices are counted hourly from the activations seen that day; the numbers hold sums only and are kept 90 days.
Groups can resolve themselves: set Resolve crash groups automatically in the product's settings (crash_auto_resolve_devices, off by default, and crash_auto_resolve_days, default 7). A new or in-progress crash group then resolves once versions above its last version ran on at least that many devices on that many days after its last report. Webhooks crash_group.created and crash_group.regressed tell your own systems about new groups and regressions.
Native frames and debug symbols
A frame of native code may carry module_build_id, the Breakpad debug ID of its module, and module_offset, the offset of the instruction in the module (0x and hex). The native handler sends both; it is the one dump_syms writes into the MODULE line: from the GNU build ID on Linux and Android, the LC_UUID on macOS, and the GUID and age of the PDB on Windows. Such frames group by module and offset, so the same crash lands in one group across starts. Upload a Breakpad symbol file for each build from your pipeline, and the dashboard and the API show function, file and line for these frames:
dump_syms target/release/app > app.sym # Linux, Android
dump_syms target/release/app.dSYM > app.sym # macOS, from the dSYM bundle
dump_syms target/release/app.pdb > app.sym # Windows, from the PDB
release-tool symbols --product prod_... app.sym
The key needs symbols:write; a key bound to the product or an OIDC trust may carry it. Uploading a file of the same debug ID again replaces it. A file may hold 512 MiB, a product 10 GiB. Symbols stay on the server: they are never sent to devices and cannot be downloaded. The API is POST /v1/products/{id}/debug-symbols, POST /v1/debug-symbols/{id}/complete, GET /v1/products/{id}/debug-symbols and DELETE /v1/debug-symbols/{id}.
The protocol is described in section 6.13.