Skip to content

Access violation on program exit when unloading models #511

@f2bo

Description

@f2bo

(Originally reported here because it was related, but the issue was closed without being addressed).

I wanted to test the latest changes to SDK V2 in the main branch, so I updated the projects in the FoundrySamplesWinML solution replacing the Microsoft.AI.Foundry.Local.WinML NuGet package reference with a reference to the Microsoft.AI.Foundry.Local project in this repo. When I do this, on my development machine, I get an access violation in dxcompiler.dll when the program exits.

Unhandled exception at 0x00007FFC3C8138C0 (dxcompiler.dll) in HelloFoundryLocalSdk.exe: 0xC0000005: Access violation reading location 0x0000000000000008.

Call Stack

dxcompiler.dll!00007ffc3c8138c0()
dxcompiler.dll!00007ffc3c568f3c()
dxcompiler.dll!00007ffc3c568f73()
dxcompiler.dll!00007ffc3c4bd1f0()
[Inline Frame] onnxruntime.dll!Microsoft::WRL::ComPtr<IDxcValidator>::InternalRelease() Line 235
	at C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\winrt\wrl\client.h(235)
[Inline Frame] onnxruntime.dll!Microsoft::WRL::ComPtr<IDxcValidator>::{dtor}() Line 290
	at C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\winrt\wrl\client.h(290)
onnxruntime.dll!dawn::native::d3d12::Backend::`scalar deleting destructor'(unsigned int)
onnxruntime.dll!`eh vector destructor iterator'(void * ptr, unsigned __int64 size, unsigned __int64 count, void(*)(void *) destructor)
onnxruntime.dll!dawn::native::InstanceBase::~InstanceBase() Line 224
	at E:\_work\1\b\RelWithDebInfo\_deps\dawn-src\src\dawn\native\Instance.cpp(224)
onnxruntime.dll!dawn::native::InstanceBase::`scalar deleting destructor'(unsigned int)
onnxruntime.dll!dawn::native::InstanceBase::DeleteThis() Line 245
	at E:\_work\1\b\RelWithDebInfo\_deps\dawn-src\src\dawn\native\Instance.cpp(245)
ucrtbase.dll!<lambda>(void)()
ucrtbase.dll!__crt_seh_guarded_call<int>::operator()<<lambda_7777bce6b2f8c936911f934f8298dc43>,<lambda>(void) &,<lambda_3883c3dff614d5e0c5f61bb1ac94921c>>()
ucrtbase.dll!_execute_onexit_table()
onnxruntime.dll!dllmain_crt_process_detach(const bool is_terminating) Line 182
	at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp(182)
onnxruntime.dll!dllmain_dispatch(HINSTANCE__ * const instance, const unsigned long reason, void * const reserved) Line 293
	at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp(293)
ntdll.dll!LdrpCallInitRoutineInternal()
ntdll.dll!LdrpCallInitRoutine()
ntdll.dll!LdrShutdownProcess()
ntdll.dll!RtlExitUserProcess()
kernel32.dll!ExitProcessImplementation()
ucrtbase.dll!common_exit()
HelloFoundryLocalSdk.exe!00007ff7aa6325af()
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()

It appears to be related to the disposal of resources by the ONNX runtime. For example, when I comment out the code to unload the model it doesn't happen, although I do get notified of the leak of some OGAHandles, as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions