From 5d6578b9d58d7ad46503d9124cccf8a68ecd5902 Mon Sep 17 00:00:00 2001 From: cheneym2 Date: Tue, 11 Mar 2025 14:12:33 -0400 Subject: Don't crash when precompiling twice (#6576) Abort precompileForTarget if it's already done. Fixes #6516 --- tools/gfx-unit-test/precompiled-module-2.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/gfx-unit-test/precompiled-module-2.cpp b/tools/gfx-unit-test/precompiled-module-2.cpp index 792f328b0..87420aa6e 100644 --- a/tools/gfx-unit-test/precompiled-module-2.cpp +++ b/tools/gfx-unit-test/precompiled-module-2.cpp @@ -59,8 +59,15 @@ static Slang::Result precompileProgram( (void**)precompileService.writeRef()) == SLANG_OK) { Slang::ComPtr diagnosticsBlob; - precompileService->precompileForTarget(target, diagnosticsBlob.writeRef()); + auto res = precompileService->precompileForTarget(target, diagnosticsBlob.writeRef()); diagnoseIfNeeded(diagnosticsBlob); + SLANG_RETURN_ON_FAIL(res); + + // compile a second time to check for driver bugs. + diagnosticsBlob = nullptr; + res = precompileService->precompileForTarget(target, diagnosticsBlob.writeRef()); + diagnoseIfNeeded(diagnosticsBlob); + SLANG_RETURN_ON_FAIL(res); } } -- cgit v1.2.3