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 #9463: [Win32] Try to work around XAudio2 crashes by catching SEH exceptions. #9549

Merged
merged 1 commit into from Sep 11, 2021

Conversation

@michicc
Copy link
Member

@michicc michicc commented Sep 11, 2021

Motivation / Problem

While it looks like the XAudio2 crashes reported e.g. in #9463 are caused by third-party components, users will still blame OpenTTD at first. As such, if we can do something, user experience is improved, especially as other audio drivers besides XAudio2 are available.

Description

The provided crash logs point to an illegal access exception during XAudio2 creation. Windows reports such errors using the SEH mechanism which can be caught by platform-specific code. If a SEH exception is encountered, just fail driver creation and let the system do the normal fallback.

The extra function is needed as SEH handling can't be used in contexts that rely on C++ unwinding.

Limitations

As I don't have the suspected third-party software components, I can't verify if this PR actually fixes the reported issues.

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 touches english.txt or translations? Check the guidelines
  • 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')
…ing SEH exceptions.

If an exceptions is thrown during context creation, just declare the XAudio
driver as unusable. The driver logic will try to find an alternative for us.
@glx22
Copy link
Contributor

@glx22 glx22 commented Sep 11, 2021

In theory it should work, but I can't test it.

Loading

Copy link
Member

@TrueBrain TrueBrain left a comment

Doubt it makes the situation worse, so sure, why not :)

Loading

@michicc michicc merged commit ee57afc into OpenTTD:master Sep 11, 2021
15 checks passed
Loading
@michicc michicc deleted the pr/bug_9463 branch Sep 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants