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

feat: Add crash recovery on Windows #5012

Merged
merged 28 commits into from
Dec 24, 2023
Merged

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Dec 10, 2023

Description

This PR adds effectively re-enables the possibility for Chatterino to restart after a crash on Windows, which was removed in #4351. To restart, we build a custom crash handler that captures some info about the crash and restarts the app (with its arguments) after Crashpad is done processing the crash. Crash recovery is only enabled in release mode. Because crash recovery and set-up of Crashpad happens before the settings are initialized, settings for crash recovery are saved in a separate file (<crashdump-dir>/chatterino-recovery.bin).

I put the handler into a new directory called auxiliary as I couldn't find/come up with anything better. The handler is only enabled on Windows.

The dialog that shows after a crash happened now contains more information about the crash (exception and where it was saved).

As for the change in .clang-tidy: cppcoreguidelines-avoid-c-arrays is already enabled and does the same.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 25 out of 36. Check the log or trigger a new build to see more.

auxiliary/crash-handler/commandline.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/main.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/recovery.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/recovery.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/recovery.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/recovery_test.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/recovery_test.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/recovery_test.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/recovery_test.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/win_support.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

auxiliary/crash-handler/win_support_test.cpp Outdated Show resolved Hide resolved
src/singletons/Crashpad.cpp Outdated Show resolved Hide resolved
src/widgets/dialogs/LastRunCrashDialog.cpp Outdated Show resolved Hide resolved
src/widgets/dialogs/LastRunCrashDialog.cpp Outdated Show resolved Hide resolved
src/widgets/dialogs/LastRunCrashDialog.cpp Outdated Show resolved Hide resolved
src/widgets/dialogs/LastRunCrashDialog.cpp Outdated Show resolved Hide resolved
src/widgets/dialogs/LastRunCrashDialog.cpp Show resolved Hide resolved
src/widgets/dialogs/LastRunCrashDialog.hpp Outdated Show resolved Hide resolved
@Nerixyz Nerixyz force-pushed the feat/win-restart branch 3 times, most recently from 8426335 to 453daf5 Compare December 10, 2023 17:05
Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shallow review

auxiliary/CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated
@@ -244,4 +244,6 @@ if (BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif ()

add_subdirectory(auxiliary)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need the auxiliary subdir, could crash-handler just not live in the repo root dir?

Copy link
Contributor Author

@Nerixyz Nerixyz Dec 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I chose a subdirectory is that I expect other tools to live here in the future and for those to not pollute the top level directory. For example, if plugins get some CLI or there's some qt plugin, this could live there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, the crashpad project should be a submodule, and it will live under tools. Neither of these things need to be actioned until this has been approved

src/widgets/dialogs/LastRunCrashDialog.cpp Outdated Show resolved Hide resolved
src/widgets/dialogs/LastRunCrashDialog.cpp Outdated Show resolved Hide resolved
src/widgets/dialogs/LastRunCrashDialog.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/recovery.cpp Outdated Show resolved Hide resolved
src/singletons/Crashpad.hpp Outdated Show resolved Hide resolved
src/widgets/dialogs/LastRunCrashDialog.cpp Outdated Show resolved Hide resolved
src/widgets/dialogs/LastRunCrashDialog.cpp Outdated Show resolved Hide resolved
src/widgets/dialogs/LastRunCrashDialog.cpp Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 25 out of 29. Check the log or trigger a new build to see more.

auxiliary/crash-handler/src/Recovery.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/src/Recovery.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/src/Recovery.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/src/Recovery.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/src/Recovery.hpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/tests/RecoveryTest.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/tests/RecoveryTest.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/tests/RecoveryTest.cpp Outdated Show resolved Hide resolved
auxiliary/crash-handler/tests/WinSupportTest.cpp Outdated Show resolved Hide resolved
src/singletons/CrashHandler.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/singletons/CrashHandler.cpp Outdated Show resolved Hide resolved
src/RunGui.cpp Outdated Show resolved Hide resolved
src/common/Args.cpp Outdated Show resolved Hide resolved
src/common/Args.cpp Outdated Show resolved Hide resolved
@Nerixyz Nerixyz requested a review from pajlada December 23, 2023 12:00
@pajlada pajlada merged commit 25add89 into Chatterino:master Dec 24, 2023
20 checks passed
@Nerixyz Nerixyz deleted the feat/win-restart branch December 24, 2023 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants