fix(shader): recover gracefully from GLSL compile/link failures instead of crashing#583
Conversation
…ad of crashing (#568) OpenGLShader treated a user-authored GLSL compile/link failure as an engineering invariant violation, calling OLO_CORE_VERIFY(false, ...) which OLO_DEBUGBREAK()s in Debug builds and kills the editor whenever a developer edits a shader into a broken state. Replace all 5 crash sites with the existing OLO_CORE_CRITICAL log plus a clean transition to ShaderCompilationStatus::Failed, propagating failure through both constructors and Reload() so no further compile/link stage runs on stale data. Also fixes a second, previously-latent crash this change exposed: the parallel-compile lambdas in CompileOrGetVulkanBinaries / CompileOrGetOpenGLBinaries assigned their result's Stage field *after* the hasError early-exit check, so a task that never ran left its result default-constructed (Stage=0). Once the fail-fast VERIFY no longer aborted on the first failure, the sequential collect loop would reach that never-run result and call GLShaderStageToString(0), hitting its own switch-default assert. Moved the Stage assignment before the early-exit check in both lambdas. Adds a regression test driving real broken GLSL through the compile path and documents the ParallelFor result-struct gotcha in docs/agent-rules/cpp-coding-quality.md for future parallel-aggregation refactors. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughOpenGLShader's Vulkan and OpenGL cross-compilation helpers now return bool instead of void, propagating per-stage compile failures to callers. Constructors, AMD program creation, and Reload() check these results and set m_CompilationStatus to Failed instead of continuing unconditionally. Hard verify/assert calls on link/compile failure are removed, AMD failure paths now clean up partially-created shader objects, and a regression test suite plus a supporting coding-quality doc rule are added. ChangesShader compile failure recovery
Possibly related issues
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
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. Comment |
- Remove a stray glCreateProgram() call in CompileOrGetVulkanBinaries() whose result was immediately discarded, leaking a GL program object on every shader compile. - Set m_CompilationStatus = Failed in the AMD driver-version-parse failure branch (missing space in the GL_VERSION string), matching every other failure path touched by this fix instead of leaving the shader stuck at Pending. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|



Summary
OpenGLShaderlogged the error viaOLO_CORE_CRITICALand then calledOLO_CORE_VERIFY(false, ...), whichOLO_DEBUGBREAK()s in Debug builds — crashing the editor whenever a developer edited a shader into a broken state. Replaced all 5 crash sites (SPIR-V compile, SPIR-V cross-compile, sync GL link, AMD link, AMD per-stage compile) with the existing critical log plus a clean transition toShaderCompilationStatus::Failed, propagated through bothOpenGLShaderconstructors andReload()so no further compile/link stage runs on stale data.CompileOrGetVulkanBinaries/CompileOrGetOpenGLBinariesassigned their result'sStagefield after thehasErrorearly-exit check, so a task that never ran left its result default-constructed (Stage=0). Once the fail-fastVERIFYno longer aborted on the first failure, the sequential collect loop reached that never-run result and calledGLShaderStageToString(0), hitting its own switch-default assert. Fixed by moving theStageassignment before the early-exit check in both lambdas.ShaderCompileFailureRecoveryTest.cpp, driving real broken GLSL through the compile path and asserting no crash +Failedstatus +rendererID == 0.ParallelForresult-struct gotcha indocs/agent-rules/cpp-coding-quality.mdfor future parallel-aggregation refactors.Closes #568
Test plan
ShaderCompileFailureRecoveryTest(3 tests) passes*Shader*,*McpShaderReload*,AssetContentValidity.*) passesRenderer2D_Line.glslwith a real syntax error, confirmed the editor now boots through it (logs the error, reachesFailedstatus, keeps rendering) instead of crashing; restored the shader and confirmed a clean recompileSummary by CodeRabbit
Bug Fixes
Documentation