Skip to content

Crashes in WinUI not caught #644

@levinli303

Description

@levinli303

Crashes in WinUI are not caught by Crashpad/Breakpad

When does the problem happen

  • During build
  • During run-time
  • When capturing a hard crash

Environment

Steps To Reproduce

  1. Create a WinUI 3 C++ packaged app project based on the template provided by Windows App SDK
  2. Initialize sentry in App::OnLaunched and use a custom logger to view output
void custom_sentry_logger(sentry_level_t level, const char* message, va_list args, void* userdata)
{
    // TODO: generate formatted string
    OutputDebugStringA(message);
}
    sentry_options_t* options = sentry_options_new();
    sentry_options_set_dsn(options, "xxx");
    auto installedLocation = Windows::ApplicationModel::Package::Current().InstalledLocation();
    sentry_options_set_handler_path(options, to_string(installedLocation.Path() + L"\\crashpad_handler.exe").c_str());
    auto localFolder = Windows::Storage::ApplicationData::Current().LocalFolder();
    auto path = localFolder.Path();
    sentry_options_set_database_path(options, to_string(localFolder.Path()).c_str());
    sentry_options_set_logger(options, custom_sentry_logger, nullptr);
    sentry_options_set_debug(options, 1);
    sentry_init(options);
  1. Crash the app in MainWindow::myButton_Click
volatile char* invalid_memory = nullptr;
*invalid_memory = '\0';  // crash
  1. Build the app in Release/x64, ensure sentry DLLs and crashpad_handler.exe are copied
  2. Run the app without a debugger, and see the log from DebugView
  3. Click the "Click Me" button which calls the code that will crash
  4. App crashes and crashpad_handler did not catch it (based on what is shown in DebugView)

Log output

Screen Shot 2021-12-30 at 5 00 37 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions