From 7119d9cb487d866d1c25e55eafa03aca6e5e52e3 Mon Sep 17 00:00:00 2001 From: aidanfnv Date: Mon, 7 Jul 2025 11:03:39 -0700 Subject: Catch abort exception from leaking from loadModule (#7627) --- source/slang/slang.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 9bfc2bce9..e76ff7436 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -1496,13 +1496,29 @@ static void outputExceptionDiagnostic( DiagnosticSink& sink, slang::IBlob** outDiagnostics) { - sink.diagnoseRaw(Severity::Internal, exception.Message.getUnownedSlice()); + try + { + sink.diagnoseRaw(Severity::Internal, exception.Message.getUnownedSlice()); + } + catch (const AbortCompilationException&) + { + // Catch and ignore the AbortCompilationException that diagnoseRaw throws + // for Internal severity to prevent exception leak from loadModule + } sink.getBlobIfNeeded(outDiagnostics); } static void outputExceptionDiagnostic(DiagnosticSink& sink, slang::IBlob** outDiagnostics) { - sink.diagnoseRaw(Severity::Fatal, "An unknown exception occurred"); + try + { + sink.diagnoseRaw(Severity::Fatal, "An unknown exception occurred"); + } + catch (const AbortCompilationException&) + { + // Catch and ignore the AbortCompilationException that diagnoseRaw throws + // for Fatal severity to prevent exception leak from loadModule + } sink.getBlobIfNeeded(outDiagnostics); } -- cgit v1.2.3