Skip to content

Feature/add depth texture#11

Merged
kimkulling merged 2 commits into
mainfrom
feature/add_depth_texture
Jun 10, 2026
Merged

Feature/add depth texture#11
kimkulling merged 2 commits into
mainfrom
feature/add_depth_texture

Conversation

@kimkulling

@kimkulling kimkulling commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes
    • Improved error reporting for graphics operations with more descriptive failure messages during rendering pipeline setup.
    • Enhanced device extension validation to ensure proper graphics capability detection during initialization.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR introduces a custom SegfaultException class and systematically replaces generic exception types (std::runtime_error, std::invalid_argument) with it throughout the Vulkan renderer. The changes also implement proper device extension validation, improve const-correctness, and apply minor cleanup.

Changes

Custom Exception Infrastructure and Renderer Error Handling

Layer / File(s) Summary
Exception type definition and build integration
src/runtime/core/segfaultexception.h, src/runtime/CMakeLists.txt
Defines SegfaultException as a std::exception subclass storing a string message, with an explicit constructor and what() override. The header is added to the CMake source list for the segfault_runtime shared library.
RHIVulkan wiring, const-correctness, and initialization
src/runtime/renderer/RHIVulkan.cpp
Includes the SegfaultException header and adds using namespace segfault::core. Adds const-qualifiers to QueueFamilyIndices::isComplete() and RHIImpl::chooseSwapSurfaceFormat() declarations and definition. Value-initializes textureSampler member.
Device extension support validation
src/runtime/renderer/RHIVulkan.cpp
Implements checkDeviceExtensionSupport(VkPhysicalDevice ...) by enumerating device extensions and filtering against required extensions; returns whether all required extensions are present (previously stubbed as return true).
Comprehensive error path consolidation to SegfaultException
src/runtime/renderer/RHIVulkan.cpp
Replaces 25 error paths with SegfaultException throws across descriptor set layout, graphics pipeline, buffer, image, framebuffer, command pool, command buffer, sync object, frame acquisition, queue submission, image view, sampler, descriptor pool, and image layout operations.
File manager stat call refactoring
src/runtime/core/genericfilemanager.cpp
Updates GenericFileManager::getArchiveStat to use const int err for both Windows and Unix stat branches; Unix call is explicitly namespace-qualified with ::.

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related PRs

  • kimkulling/Segfault#10: Both PRs modify transitionImageLayout error handling in RHIVulkan.cpp, with this PR replacing the exception type and #10 handling depth-stencil/depth layout support.
  • kimkulling/Segfault#7: Both PRs modify RHIVulkan.cpp, building on the texture sampler and image view implementation from PR #7 with systematic error handling updates.

Suggested Labels

enhancement

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Feature/add depth texture' is partially related to the changeset. While depth texture support may be the ultimate feature goal, the actual changes focus on adding a custom exception class, adjusting error handling throughout the Vulkan renderer, fixing method const-qualifiers, and improving device extension checking—none of which directly implement depth texture functionality. Consider revising the title to reflect the primary technical changes, such as 'Refactor error handling with SegfaultException and improve Vulkan validation' or providing clarification on how these changes enable depth texture support.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/add_depth_texture

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/runtime/core/genericfilemanager.cpp

src/runtime/core/genericfilemanager.cpp:1:10: fatal error: 'core/genericfilemanager.h' file not found
1 | #include "core/genericfilemanager.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/3d8f7594032800e3d74cf5dec6cb9fd5d12d2f76-6814cdf862438789/tmp/clang_command_.tmp.50a97a.txt
++Contents of '/tmp/coderabbit-infer/3d8f7594032800e3d74cf5dec6cb9fd5d12d2f76-6814cdf862438789/tmp/clang_command_.tmp.50a97a.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-li

... [truncated 1137 characters] ...

clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/6814cdf862438789/file.o" "-x" "c++"
"src/runtime/core/genericfilemanager.cpp" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"

src/runtime/renderer/RHIVulkan.cpp

In file included from src/runtime/renderer/RHIVulkan.cpp:1:
src/runtime/renderer/RHI.h:3:10: fatal error: 'core/segfault.h' file not found
3 | #include "core/segfault.h"
| ^~~~~~~~~~~~~~~~~
1 error generated.
Aborting translation of method 'segfault::renderer::RHIImpl::createDebugUtilsMessengerEXT' in file 'src/runtime/renderer/RHIVulkan.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAst_utils.ml:249:53"
Error backtrace:
Raised at ClangFrontend__CAst_utils.get_decl_from_typ_ptr in file "src/clang/cAst_utils.ml", line 249, characters 53-65
Called from ClangFrontend__CTrans.CTrans_funct.get_destructor_decl_ref in file "src/clang/cTrans.ml", line 658, characters 12-59
Called from ClangFrontend__CTrans.CTrans_funct.destructor_calls.(fun) in file "src/clang/cTrans.ml", line 2048, characters 12-69
Called from Base__List.rev_filter_map.loop in file "src/list.ml", line 944, characters 13-17
Called from Base__List.fil

... [truncated 2200 characters] ...

end_decl.ml" (inlined), line 54, characters 4-52
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.process_method_decl.add_method_if_create_procdesc in file "src/clang/cFrontend_decl.ml" (inlined), line 123, characters 16-158
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.process_method_decl in file "src/clang/cFrontend_decl.ml", line 126, characters 17-97
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.process_methods in file "src/clang/cFrontend_decl.ml" (inlined), line 270, characters 8-122
Called from Stdlib__List.iter in file "list.ml" (inlined), line 110, characters 12-15
Called from Stdlib__List.iter in file "list.ml" (inlined), line 108, characters 13-64
Called from Base__List0.iter in file "src/list0.ml" (inlined), line 25, characters 16


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
2 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/runtime/core/segfaultexception.h`:
- Line 1: Add the project-mandated MIT license header to the top of the new
header file src/runtime/core/segfaultexception.h by inserting the standard
multi-line MIT banner used across the repo before the existing `#pragma` once;
ensure the header text matches the exact format used in other .h/.cpp files
(including year and copyright holder) so the file complies with "Include MIT
license header in all source files" policy.

In `@src/runtime/renderer/RHIVulkan.cpp`:
- Around line 318-323: The Vulkan extension enumeration in
RHIImpl::checkDeviceExtensionSupport(VkPhysicalDevice) leaves extensionCount
uninitialized and ignores vkEnumerateDeviceExtensionProperties return values;
change to initialize uint32_t extensionCount = 0, call
vkEnumerateDeviceExtensionProperties and check its VkResult for success before
using extensionCount, bail out (return false or handle error) if the call fails,
then allocate/resize the std::vector<VkExtensionProperties> to extensionCount
and call vkEnumerateDeviceExtensionProperties again while checking its result;
ensure you validate extensionCount (e.g., zero means no extensions) before using
availableExtensions.
- Around line 1025-1026: Wrap calls into the RHI boundary so SegfaultException
cannot escape: in the public RHI API entry points (RHI::init() and
RHI::drawFrame()) catch segfault::core::SegfaultException and convert it to a
safe failure (return false from RHI::init() and return from RHI::drawFrame()
without throwing), logging the error; likewise add try/catch in higher-level
callers (App::drawFrame() and main) where they call
RHIImpl::drawFrame()/RHI::drawFrame() to ensure any remaining
segfault::core::SegfaultException is caught, logged, and translated to a
controlled shutdown path rather than allowing the exception to propagate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3035a2d9-27aa-4221-b5e7-8b6c84bd4f73

📥 Commits

Reviewing files that changed from the base of the PR and between f0c703e and 3d8f759.

📒 Files selected for processing (4)
  • src/runtime/CMakeLists.txt
  • src/runtime/core/genericfilemanager.cpp
  • src/runtime/core/segfaultexception.h
  • src/runtime/renderer/RHIVulkan.cpp

@@ -0,0 +1,27 @@
#pragma once

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add the required MIT license header.

Line 1 starts a new .h file without the project-mandated MIT license banner.

As per coding guidelines, "Include MIT license header in all source files" for **/*.{h,cpp}.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/runtime/core/segfaultexception.h` at line 1, Add the project-mandated MIT
license header to the top of the new header file
src/runtime/core/segfaultexception.h by inserting the standard multi-line MIT
banner used across the repo before the existing `#pragma` once; ensure the header
text matches the exact format used in other .h/.cpp files (including year and
copyright holder) so the file complies with "Include MIT license header in all
source files" policy.

Source: Coding guidelines

Comment on lines +318 to +323
bool RHIImpl::checkDeviceExtensionSupport(VkPhysicalDevice device_) {
uint32_t extensionCount;
vkEnumerateDeviceExtensionProperties(device_, nullptr, &extensionCount, nullptr);

std::vector<VkExtensionProperties> availableExtensions(extensionCount);
vkEnumerateDeviceExtensionProperties(device_, nullptr, &extensionCount, availableExtensions.data());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify all extension-enumeration call sites and whether return values are checked.
rg -nP 'vkEnumerateDeviceExtensionProperties\s*\(' src/runtime/renderer/RHIVulkan.cpp -C3

Repository: kimkulling/Segfault

Length of output: 1122


Initialize and validate Vulkan extension-enumeration results in RHIImpl::checkDeviceExtensionSupport(VkPhysicalDevice)

At src/runtime/renderer/RHIVulkan.cpp lines 318-323, extensionCount is left uninitialized and both vkEnumerateDeviceExtensionProperties calls ignore the returned VkResult; if enumeration fails, this can produce an invalid extensionCount and unsafe vector sizing.

🛠️ Proposed fix
 bool RHIImpl::checkDeviceExtensionSupport(VkPhysicalDevice device_) {
-    uint32_t extensionCount;
-    vkEnumerateDeviceExtensionProperties(device_, nullptr, &extensionCount, nullptr);
+    uint32_t extensionCount{};
+    VkResult result = vkEnumerateDeviceExtensionProperties(device_, nullptr, &extensionCount, nullptr);
+    if (result != VK_SUCCESS) {
+        return false;
+    }
 
     std::vector<VkExtensionProperties> availableExtensions(extensionCount);
-    vkEnumerateDeviceExtensionProperties(device_, nullptr, &extensionCount, availableExtensions.data());
+    result = vkEnumerateDeviceExtensionProperties(device_, nullptr, &extensionCount, availableExtensions.data());
+    if (result != VK_SUCCESS) {
+        return false;
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
bool RHIImpl::checkDeviceExtensionSupport(VkPhysicalDevice device_) {
uint32_t extensionCount;
vkEnumerateDeviceExtensionProperties(device_, nullptr, &extensionCount, nullptr);
std::vector<VkExtensionProperties> availableExtensions(extensionCount);
vkEnumerateDeviceExtensionProperties(device_, nullptr, &extensionCount, availableExtensions.data());
bool RHIImpl::checkDeviceExtensionSupport(VkPhysicalDevice device_) {
uint32_t extensionCount{};
VkResult result = vkEnumerateDeviceExtensionProperties(device_, nullptr, &extensionCount, nullptr);
if (result != VK_SUCCESS) {
return false;
}
std::vector<VkExtensionProperties> availableExtensions(extensionCount);
result = vkEnumerateDeviceExtensionProperties(device_, nullptr, &extensionCount, availableExtensions.data());
if (result != VK_SUCCESS) {
return false;
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/runtime/renderer/RHIVulkan.cpp` around lines 318 - 323, The Vulkan
extension enumeration in RHIImpl::checkDeviceExtensionSupport(VkPhysicalDevice)
leaves extensionCount uninitialized and ignores
vkEnumerateDeviceExtensionProperties return values; change to initialize
uint32_t extensionCount = 0, call vkEnumerateDeviceExtensionProperties and check
its VkResult for success before using extensionCount, bail out (return false or
handle error) if the call fails, then allocate/resize the
std::vector<VkExtensionProperties> to extensionCount and call
vkEnumerateDeviceExtensionProperties again while checking its result; ensure you
validate extensionCount (e.g., zero means no extensions) before using
availableExtensions.

Comment on lines +1025 to 1026
throw SegfaultException("failed to acquire swap chain image!");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify throw/catch balance around public API boundaries.
rg -nP '^\s*(bool|void)\s+RHI::(init|drawFrame)\s*\(' src/runtime/renderer/RHIVulkan.cpp -A120
rg -nP '\bthrow\s+SegfaultException\s*\(' src/runtime/renderer/RHIVulkan.cpp
rg -nP '\bcatch\s*\(' src/runtime/renderer/RHIVulkan.cpp

Repository: kimkulling/Segfault

Length of output: 8447


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="src/runtime/renderer/RHIVulkan.cpp"

# Show context around the specific throw sites mentioned in the review
sed -n '1000,1100p' "$file" | cat -n

# Find the RHIImpl drawFrame implementation and show around it
rg -n "drawFrame\\s*\\(" "$file" | head -n 20
# also dump a larger window around the likely drawFrame impl region
sed -n '1600,1750p' "$file" | cat -n

# Confirm whether any catch exists anywhere in this file
rg -n "\\bcatch\\b" "$file" || true

Repository: kimkulling/Segfault

Length of output: 8214


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Find any catches for SegfaultException anywhere in the repo
rg -n --hidden --no-ignore-vcs --glob='!**/node_modules/**' 'catch\s*\(\s*[^)]*SegfaultException' . || true
rg -n --hidden --no-ignore-vcs --glob='!**/node_modules/**' 'SegfaultException' . | head -n 50

# 2) Find call sites of RHI::drawFrame()
rg -n '\.drawFrame\s*\(\s*\)\s*;' src || true
rg -n 'RHI::drawFrame\s*\(' . || true

# 3) Inspect the loop where drawFrame is called most likely (grab a few hits)
# (Use only a small amount of context to avoid huge output)
rg -n '\.drawFrame\s*\(\s*\)\s*;' src -n -C 3 || true

Repository: kimkulling/Segfault

Length of output: 3789


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Find any catch blocks that might intercept exceptions generically
rg -n --hidden --no-ignore-vcs --glob='!**/node_modules/**' '\bcatch\s*\(' src | head -n 200

# 2) Inspect SegfaultException definition
if [ -f src/runtime/core/segfaultexception.h ]; then
  nl -ba src/runtime/core/segfaultexception.h | sed -n '1,120p'
fi

# 3) Inspect hello_world drawFrame callsite and surrounding code
nl -ba src/examples/hello_world/hello_world.cpp | sed -n '1,120p'

# 4) Trace where myApp.drawFrame() is implemented (look for "drawFrame()" method in app classes)
rg -n 'drawFrame\s*\(\s*\)' src/runtime src/examples | head -n 200

Repository: kimkulling/Segfault

Length of output: 45


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Find any catch blocks that might intercept exceptions
rg -n --hidden --no-ignore-vcs --glob='!**/node_modules/**' '\bcatch\s*\(' src || true | head -n 200

# 2) Inspect SegfaultException definition
if [ -f src/runtime/core/segfaultexception.h ]; then
  nl -ba src/runtime/core/segfaultexception.h | sed -n '1,160p'
fi

# 3) Inspect hello_world drawFrame callsite and surrounding code
nl -ba src/examples/hello_world/hello_world.cpp | sed -n '1,200p'

# 4) Locate implementations of drawFrame() methods (likely app delegates)
rg -n '(\b|::)drawFrame\s*\(\s*\)' src/runtime src/examples || true

# 5) Locate main loop / drawFrame routing (look for "mainloop" and "RHI")
rg -n 'mainloop\s*\(\s*\)|RHI::drawFrame|myApp\.drawFrame|drawFrame\s*\(\s*\)\s*;' src/examples src/runtime || true

Repository: kimkulling/Segfault

Length of output: 106


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Find any catch blocks that might intercept exceptions
rg -n --hidden --no-ignore-vcs --glob='!**/node_modules/**' '\bcatch\s*\(' src || true | head -n 200

# 2) Inspect SegfaultException definition
if [ -f src/runtime/core/segfaultexception.h ]; then
  cat -n src/runtime/core/segfaultexception.h | sed -n '1,200p'
fi

# 3) Inspect hello_world drawFrame callsite and surrounding code
if [ -f src/examples/hello_world/hello_world.cpp ]; then
  cat -n src/examples/hello_world/hello_world.cpp | sed -n '1,220p'
fi

# 4) Locate implementations of drawFrame() methods (avoid matching RHI::drawFrame signature only by including "void ...::drawFrame")
rg -n 'void\s+([A-Za-z_]\w*::)?drawFrame\s*\(' src/runtime src/examples || true | head -n 200

# 5) Locate main loop / routing
rg -n 'mainloop\s*\(\s*\)|myApp\.drawFrame\s*\(\s*\)|RHI::drawFrame\s*\(' src/examples src/runtime || true | head -n 200

Repository: kimkulling/Segfault

Length of output: 2325


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file_app="src/runtime/application/app.cpp"
file_apph="src/runtime/application/app.h"
file_rhi="src/runtime/renderer/RHI.h"
file_rhi_impl="src/runtime/renderer/RHIVulkan.cpp"

# Show drawFrame/mainloop implementations with surrounding context
cat -n "$file_app" | sed -n '1,220p'
echo "----"
cat -n "$file_app" | sed -n '220,420p' || true

echo "---- RHI.h ----"
cat -n "$file_rhi" | sed -n '1,140p'

echo "---- RHI::drawFrame call in App::drawFrame ----"
rg -n "drawFrame\\s*\\(\\s*\\)" "$file_app" "$file_apph" || true
rg -n "RHI::drawFrame|mRHI->drawFrame|drawFrame\\s*\\(" "$file_app" -n -C 3 || true

echo "---- try/catch in App:: paths ----"
rg -n "\\btry\\b|\\bcatch\\b" "$file_app" "$file_apph" "$file_rhi_impl" || true

Repository: kimkulling/Segfault

Length of output: 8246


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="src/runtime/renderer/RHIVulkan.cpp"

# Helper: print a window with nearby function header lines
for start in 180 200 600 660 760 780 800 820 860 880 900 960 980 1000 1010 1030 1060 1080 1100 1120 1140 1160 1200 1230 1300 1450; do
  echo "==== lines $start-$((start+80)) ===="
  sed -n "${start},$((start+80))p" "$file" | head -n 120
done

Repository: kimkulling/Segfault

Length of output: 50375


🏁 Script executed:

rg -n --hidden --no-ignore-vcs --glob='!**/node_modules/**' '\bcatch\s*\(' src | head -n 50 || true

Repository: kimkulling/Segfault

Length of output: 45


🏁 Script executed:

#!/bin/bash
set -euo pipefail
file="src/runtime/renderer/RHIVulkan.cpp"

# Print the beginning of the file to see namespaces/includes/usings for SegfaultException
sed -n '1,120p' "$file" | cat -n

# Also show the exact RHI::init signature/namespace context (first few lines of the function)
sed -n '1500,1565p' "$file" | cat -n

Repository: kimkulling/Segfault

Length of output: 7765


Translate renderer exceptions at the RHI API boundary.

RHIImpl::drawFrame() throws SegfaultException on swapchain acquire/submit/present failures, but neither RHI::drawFrame() (void) nor RHI::init() (bool) catches, and App::drawFrame()/main have no exception handling either—so these exceptions can escape the RHI boundary and terminate the process instead of controlled failure.

Add boundary handling around RHI::init() and RHI::drawFrame() to catch segfault::core::SegfaultException and map to false (and/or a log) / safely return without propagating.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/runtime/renderer/RHIVulkan.cpp` around lines 1025 - 1026, Wrap calls into
the RHI boundary so SegfaultException cannot escape: in the public RHI API entry
points (RHI::init() and RHI::drawFrame()) catch
segfault::core::SegfaultException and convert it to a safe failure (return false
from RHI::init() and return from RHI::drawFrame() without throwing), logging the
error; likewise add try/catch in higher-level callers (App::drawFrame() and
main) where they call RHIImpl::drawFrame()/RHI::drawFrame() to ensure any
remaining segfault::core::SegfaultException is caught, logged, and translated to
a controlled shutdown path rather than allowing the exception to propagate.

Source: Coding guidelines

@kimkulling kimkulling merged commit 4e58c3a into main Jun 10, 2026
5 checks passed
@kimkulling kimkulling deleted the feature/add_depth_texture branch June 10, 2026 09:15
@kimkulling kimkulling self-assigned this Jun 10, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jun 16, 2026
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.

1 participant