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

Fix #8860: [Win32] Crashlog window wasn't reliably shown for crashes. #8861

Merged
merged 1 commit into from Mar 13, 2021

Conversation

michicc
Copy link
Member

@michicc michicc commented Mar 13, 2021

Motivation / Problem

If a crash occurs on a different thread to the main thread, the crashlog window wasn't reliably shown on windows.

Description

Crashlog on windows relies on a captured stack pointer to always have a safe stack area. We only captured the stack pointer on the main thread, which doesn't work when calling the crashlog handler from a different thread.

To solve this, we make the stack pointer a thread local var and capture it on thread init.

Limitations

@JGRennison has an alternate suggestion in #8860, which, as far as I can see, would be enough for Windows (expect ARM64). This PR implements a solution that is more general, which in the future could be used to support thread specific things also on other platforms.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

src/crashlog.h Outdated
@@ -114,6 +114,12 @@ class CrashLog {
*/
static void InitialiseCrashLog();

/**
* Initialiser in case a newly started thread has to be prepared for the crash log.
Copy link
Member

Choose a reason for hiding this comment

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

this is a weird sentence .. initialiser in case a thread has to be prepared .. feels really vague :D Can't you make it more absolute in what it does / when it has to be called?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just copied the language from the comment for InitialiseCrashLog directly above, but you are right that it reads a bit strange.

@michicc michicc merged commit 13011e0 into OpenTTD:master Mar 13, 2021
@michicc michicc deleted the pr/crashlog_thread branch March 13, 2021 21:09
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