Skip to content

Commit 54789d0

Browse files
In dispose of BitCodeModule, Marked DIBuilder, if created, as invalid. Added checks to DiBuilder members to throw if the handle is invalid (#222)
Co-authored-by: cibuild-telliam <32618965+cibuild-telliam@users.noreply.github.com>
1 parent ff3f32f commit 54789d0

File tree

2 files changed

+43
-37
lines changed

2 files changed

+43
-37
lines changed

src/Ubiquity.NET.Llvm/BitcodeModule.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,12 @@ public void Dispose( )
293293
// finalizer, which would cause an access violation in the native LLVM layer.
294294
if( !IsDisposed )
295295
{
296+
// DI builder is owned by this module, so when it is destroyed so is the builder
297+
if(LazyDiBuilder.IsValueCreated)
298+
{
299+
LazyDiBuilder.Value.BuilderHandle.SetHandleAsInvalid();
300+
}
301+
296302
// remove the module handle from the module cache.
297303
ModuleHandle!.Dispose( );
298304
ModuleHandle = default;

0 commit comments

Comments
 (0)