summaryrefslogtreecommitdiffstats
path: root/source/slang/slang.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-09-26 15:40:22 -0400
committerGitHub <noreply@github.com>2023-09-26 12:40:22 -0700
commita18dca27392b257ba2cc58ceabdf15471f34ee25 (patch)
treee76ed8fa4fbdc3f9fa3e0ea4f1b45bde64b57eab /source/slang/slang.cpp
parent6c991942ac4ec2e2abf6abe73a2429183172af84 (diff)
Fix for epoch/ASTBuilder* nullptr issue (#3240)
* Fix issue with failing tests tests/serialization/serialized-module-test.slang tests/serialization/extern/extern-test.slang * Fix issue with session destruction order on Session. * Improve comment.
Diffstat (limited to 'source/slang/slang.cpp')
-rw-r--r--source/slang/slang.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 38ebcccd6..46ccb6ce9 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -4726,6 +4726,13 @@ void Session::addBuiltinSource(
Session::~Session()
{
+ // This is necessary because this ASTBuilder uses the SharedASTBuilder also owned by the session.
+ // If the SharedASTBuilder gets dtored before the globalASTBuilder it has a dangling pointer, which
+ // is referenced in the ASTBuilder dtor (likely) causing a crash.
+ //
+ // By destroying first we know it is destroyed, before the SharedASTBuilder.
+ globalAstBuilder.setNull();
+
// destroy modules next
stdlibModules = decltype(stdlibModules)();
}