OverviewFilesCommitsIssuesDocsReleasesPeers

nvidia-rtx-godot commits / 421b607

RT: free the hit SBT before its pipeline, not after
The last two double-frees after the BLAS fix were hit_sbt, and always the same two IDs in every run -- deterministic, so an ordering bug rather than a lifetime race. _swap_in_pipeline freed bundle.pipeline and then bundle.hit_sbt, but hit_sbt_create registers the SBT as a dependency of its pipeline (rendering_device.cpp:768), so the pipeline free already took the SBT with it via _free_dependencies and the next line freed it again. Freeing the SBT first also unregisters it from the pipeline's dependency set, so the subsequent pipeline free finds nothing to cascade. invalidate_pipeline_bundles already had this order; this path had it inverted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
421b6073f7042d1080c0489e159893039cf744f1
by plankatron <fleeky@gmail.com> · 2026-07-31T18:57:29.000Z

Changed files (1) +8 -3

servers/rendering/renderer_rd/forward_clustered/scene_shader_raytracing.cpp +8 -3
……@@ -1324,12 +1324,17 @@ void SceneShaderRaytracing::_finalize_pipeline_build(PipelineBuildTask *p_task)
13241324 }
13251325 RD::get_singleton()->hit_sbt_range_update(new_sbt, sbt_range, 0, indices);
13261326
1327 if (bundle.pipeline.is_valid()) {
1328 RD::get_singleton()->free_rid(bundle.pipeline);
1329 }
1327 // SBT before pipeline, never the other way round: hit_sbt_create registers the
1328 // SBT as a dependency of its pipeline (rendering_device.cpp:768), so freeing the
1329 // pipeline first frees the SBT with it and the next free is a double free.
1330 // Freeing the SBT first unregisters it from the pipeline's dependency set, which
1331 // is what invalidate_pipeline_bundles() already does.
13301332 if (bundle.hit_sbt.is_valid()) {
13311333 RD::get_singleton()->free_rid(bundle.hit_sbt);
13321334 }
1335 if (bundle.pipeline.is_valid()) {
1336 RD::get_singleton()->free_rid(bundle.pipeline);
1337 }
13331338 RD::get_singleton()->set_resource_name(p_task->new_pipeline, String("RT Pipeline [flags=") + itos(p_task->rt_flags) + "]");
13341339 bundle.pipeline = p_task->new_pipeline;
13351340 bundle.hit_sbt = new_sbt;