summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-11-12 14:00:35 -0500
committerGitHub <noreply@github.com>2019-11-12 14:00:35 -0500
commit166a7387cb3a83b24dd4b9279877338c758eb8b6 (patch)
treea375171dc833a70cc8d7d480d78dae730c9e0ee3 /examples
parent6ee483dc6ddbd372fb509319e0b70f7fc6152278 (diff)
Fix ref counting bug in cpu-hello-world (#1119)
* Fix ref counting bug in cpu-hello-world that meant session was not released correctly. * Fix typo.
Diffstat (limited to 'examples')
-rw-r--r--examples/cpu-hello-world/main.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/examples/cpu-hello-world/main.cpp b/examples/cpu-hello-world/main.cpp
index 4ece04da2..6e06f64bc 100644
--- a/examples/cpu-hello-world/main.cpp
+++ b/examples/cpu-hello-world/main.cpp
@@ -49,7 +49,10 @@ static SlangResult _innerMain(int argc, char** argv)
// somewhat heavy-weight operation. When possible, an application
// should try to re-use the same session across multiple compiles.
//
- ComPtr<slang::IGlobalSession> slangSession(spCreateSession(NULL));
+ // NOTE that we use attach instead of setting via assignment, as assignment will increase
+ // the refcount. spCreateSession returns a IGlobalSession with a refcount of 1.
+ ComPtr<slang::IGlobalSession> slangSession;
+ slangSession.attach(spCreateSession(NULL));
// As touched on earlier, in order to generate the final executable code,
// the slang code is converted into C++, and that C++ needs a 'prelude' which