Skip to content

libobs-d3d11: Avoid exceptions in shader cache file handling#13538

Open
notr1ch wants to merge 1 commit into
obsproject:masterfrom
notr1ch:shader-cache-noexcept
Open

libobs-d3d11: Avoid exceptions in shader cache file handling#13538
notr1ch wants to merge 1 commit into
obsproject:masterfrom
notr1ch:shader-cache-noexcept

Conversation

@notr1ch

@notr1ch notr1ch commented Jun 10, 2026

Copy link
Copy Markdown
Member

Description

We're still getting crash reports from this code and it seems like C++ file I/O with exceptions set is a minefield - even closing a file in an exception handler can trigger further exceptions from buffer flushes for example. Using std::filesystem to check the file exists before opening it also introduces exceptions and is a pointless TOCTOU check anyway.

This commit removes the exception bits from the streams and relies on ifstream operator bool and ofstream fail() instead, greatly reducing the number of possible exception generating paths we need to worry about.

Motivation and Context

Fix reported crashes.

How Has This Been Tested?

Tested with read only, deleted files, corrupt files as much as possible.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

We're still getting crash reports from this code and it seems like C++
file I/O with exceptions set is a minefield - even closing a file in an
exception handler can trigger further exceptions from buffer flushes for
example. Using std::filesystem to check the file exists before opening
it also introduces exceptions and is a pointless TOCTOU check anyway.

This commit removes the exception bits from the streams and relies on
ifstream operator bool and ofstream fail() instead, greatly reducing the
number of possible exception generating paths we need to worry about.
@notr1ch notr1ch added kind/bug Categorizes issue or PR as related to a bug. platform/windows Categorizes issue or PR as affecting Windows specifically labels Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. kind/crash platform/windows Categorizes issue or PR as affecting Windows specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants