Crash when FreeLibrary() of sdk.dll in Windows meeting SDK C++

Description
I am using Zoom meeting SDK in windows 10, SDK version 6.4.0.62547. I can load the dll, join a meeting and record video/audio properly. But when my app exits, it crashes on FreeLibrary() for Zoom sdk dll.

I used Dependencies to check if I missed any thing, but it looks fine. So I simplify my app to only call InitSDK() and CleanUPSDK(). It still crashed. The simple code is as below:

typedef SDKError (__cdecl initSDK)(InitParam& initParam);
typedef SDKError(__cdecl
cleanUpSDK)();
int main()
{
HINSTANCE zoomlib = LoadLibrary(L"sdk.dll");
auto err = GetLastError();

if (zoomlib)
{
    initSDK init = (initSDK)GetProcAddress(zoomlib, "InitSDK");
    cleanUpSDK clean = (cleanUpSDK)GetProcAddress(zoomlib, "CleanUPSDK");

    ZOOMSDK::InitParam initParam;
    initParam.strWebDomain = kZoomHost.c_str();
    initParam.strSupportUrl = kZoomHost.c_str();

    initParam.emLanguageID = ZOOMSDK::SDK_LANGUAGE_ID::LANGUAGE_English;

    initParam.enableLogByDefault = false; //true;
    initParam.enableGenerateDump = false; //true;

    auto err = init(initParam);

    std::cout << "Init Zoom SDK. err: " << err << std::endl;

    err = clean();

    std::cout << "Clean Zoom SDK. err: " << err << std::endl;

    FreeLibrary(zoomlib);
    auto error = GetLastError();
}

}

I got printout result:
Init Zoom SDK. err: 0
Error: Send error, 10051 Unknown error
Error: Send error, 10051 Unknown error
Error: Send error, 10051 Unknown error
Clean Zoom SDK. err: 0

And it got Exception Thrown on FreeLibrary(zoomlib)

Then I used WinDbg to check the stack, following is what I got:

0:000> k

Child-SP RetAddr Call Site

00 000000a2508ff3e0 00007ffdc2843c03 sdk!destroyRenderer+0x1230
01 000000a2508ff6b0 00007ffdc28428f5 sdk!Ordinal4+0x85f3
02 000000a2508ff740 00007ffdc2900749 sdk!Ordinal4+0x72e5
03 000000a2508ff770 00007ffebe8842d6 sdk!Ordinal4+0xc5139
04 000000a2508ff7a0 00007ffebe8841fb ucrtbase!<lambda_f03950bc5685219e0bcd2087efbe011e>::operator()+0xa6
05 000000a2508ff7f0 00007ffebe8841b4 ucrtbase!__crt_seh_guarded_call::operator()<<lambda_7777bce6b2f8c936911f934f8298dc43>,<lambda_f03950bc5685219e0bcd2087efbe011e> &,<lambda_3883c3dff614d5e0c5f61bb1ac94921c> >+0x3b
06 000000a2508ff820 00007ffdc2949e8d ucrtbase!execute_onexit_table+0x34
07 000000a2508ff850 00007ffdc2949fb2 sdk!RetrieveCustomizedResourceHelper+0x193dd
08 000000a2508ff890 00007ffec0f49a1d sdk!RetrieveCustomizedResourceHelper+0x19502
09 000000a2508ff8f0 00007ffec0f9badb ntdll!LdrpCallInitRoutine+0x61
0a 000000a2508ff960 00007ffec0f9b537 ntdll!LdrpProcessDetachNode+0x107
0b 000000a2508ffa30 00007ffec0f3fd0a ntdll!LdrpUnloadNode+0x3f
0c 000000a2508ffa80 00007ffec0f3fc84 ntdll!LdrpDecrementModuleLoadCountEx+0x72
0d 000000a2508ffab0 00007ffec099c1fe ntdll!LdrUnloadDll+0x94
0e 000000a2508ffae0 00007ff72391b3b0 KERNELBASE!FreeLibrary+0x1e
0f 000000a2508ffb10 00007ff7239178f9 TestZoomSDK!main+0x170 [C:\Users\jhuang\source\repos\TestZoomSDK\TestZoomSDK\TestZoomSDK.cpp @ 99]
10 000000a2508ffd80 00007ff7239177e2 TestZoomSDK!invoke_main+0x39 [D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 79]
11 000000a2508ffdd0 00007ff72391769e TestZoomSDK!__scrt_common_main_seh+0x132 [D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 288]
12 000000a2508ffe40 00007ff72391798e TestZoomSDK!__scrt_common_main+0xe [D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 331]
13 000000a2508ffe70 00007ffec0c97374 TestZoomSDK!mainCRTStartup+0xe [D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp @ 17]
14 000000a2508ffea0 00007ffec0f7cc91 KERNEL32!BaseThreadInitThunk+0x14
15 000000a2508ffed0 0000000000000000 ntdll!RtlUserThreadStart+0x21

It seems like something’s wrong with the dll. Please help! Thanks a lot!

Julie

Hi @Julie3,

it sounds like you’re running into a known issue where the SDK hasn’t fully shut down before FreeLibrary is called.

If you can, try linking the SDK via its static .lib so Windows automatically handles loading and unloading.

If that isn’t an option, be sure to release all references (audio, video, etc.) before you call CleanUPSDK(), and consider adding a small delay or pumping messages afterward. This ensures any internal SDK threads have time to exit. Also, double-check that you’re on the latest Windows Meeting SDK version, since Zoom often fixes unload-related crashes in newer releases.

Good luck, hope this helps!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.