-
Notifications
You must be signed in to change notification settings - Fork 614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
body track DLL fails to manage dependencies: ignores DLL load path, probably missing manifest, #1510
Comments
Configuring the dll search path(s) is the responsibility of the programmer not of the library. |
Hello. You seem to be a new user or perhaps a bot. Unless you can provide specific information, I believe your post is not relevant to this conversation. |
@qm13 this is a feature request. Current BTSDK doesn't support application isolation (side-by-side assemblies). The standard search order for Windows applications is used for loading linked dlls. |
@qm13, that is misleading. While LoadLibrary might be using standard path, the function
It is (1) of which I'm reporting this bug. Not (2). This is a recurring misunderstanding by your team. |
Hi @diablodale, No, VerifyDependencies is not doing what you thought. It is just a wrapper call of Windows API SearchPath. The lpPath parameter is NULL, so the default search order is similar to how system loads DLLs. |
Ah ha! You have admitted the problem.
It follows different paths, ignores apis like This is related to https://docs.microsoft.com/en-us/azure/kinect-dk/troubleshooting#using-body-tracking-sdk-with-unreal and its general topic of "finding required resources (dll,onnx,etc.) for k4a and k4abt SDKs. |
Done |
@qm13, Done in what version? For customers to verify unseeable code changes, we need to know the exact version in which is was potentially fixed so that customers can verify, escalate non-fix, etc. |
The body tracking dll
k4abt.dll
is improperly checking-for and loading dependent DLLs. This results in a failure to load k4abt.dll and cascades up to parent DLLs/EXEs.It appears k4abt.dll lacks code to manage its own DLL load path and/or a manifest. Without these, Windows follows a well defined series of steps to find body tracking dependent DLLs. And can easily lead to failures.
Many customers do not create single monolithic applications. Therefore, we create DLLs...just like K4A created two DLLs. The K4A DLLs need to play well in these scenarios.
I believe I have isolated the first errant code at
D:\a\1\s\src\TrackerHost\TrackerHost.cpp (469): VerifyDependencies()
. It is my suspicion that the code there is not respecting DLL load paths and flags. Instead, it is blindly loading from current_working_directory.Setup
Repro and Description
Result
The DLL feature fails to load. The cause is it can not find any of the body tracking depedent DLLs.
Using Sysinternals process monitor, I can see the loader trying to find these DLLs and it can not. It searchs the windows os folders, path, etc.... can't be found.
The feature DLL can successfully load k4a.dll and k4abt.dll by using its own manifest and/or hooking it via a delayload dll. Yet, even though the feature DLL loaded k4a.dll and it is in memory...that doesn't equate to the k4a.dll that is needed by k4abt.dll. When I use Sysinternals process monitor, I see the feature DLL successfully load k4.dll, then I see k4abt.dll load, then I see k4a.dll fail to load because the body tracking dll is separately loading it and fails due ot above issues.
I was able to capture some traces in the console window. Perhaps part of the issue is in your function
VerifyDependencies()
. Are you blindly using currentworkingdirectory? Or the directory of the master EXE? Ignoring flags set by SetDefaultDllDirectories() or directories set by SetDllDirectory()/AddDllDirectory()? All those are errant approaches and create the problem.In general, I think a function like VerifyDependencies() is problematic. It is the apps responsibility to check/manage dependencies with various APIs and tools like Windows Manifests. I suspect that k4abt.dll itself doesn't use a Windows manifest, therefore the windows loader doesn't look in the current or any other specific directory. In addition k4abt.dll doesn't call
SetDllDirectoryW(the_k4abt.dll_dir)
. If it did, it would look in the same directory as itself.Further...I was able to workaround this problematic VerifyDependencies() by surrounding k4abt::tracker::create() with...
When I used that hack, your VerifyDependencies() succeeded and afterwards the windows loader loaded the need DLLs.
Expected
Feature loads. No errors.
Workarounds
Hack the current working directory as above. And then use various APIs like SetDefaultDllDirectories(), SetDllDirectoryW(), and LoadLibraryExW(dllname, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR) to actually load the DLL.
Note...
SetDllDirectoryW(the_k4abt.dll_dir)
. That API only changes the search path for its own dependencies. It is not used for its dependencies dependencies.Logs
Here is a log from sysinternals process monitor. This was run with my own test code which does the following in specific order
/DELAYLOAD:k4a.dll /DELAYLOAD:k4abt.dll
SetDllDirectoryW(plugin_dll_dir); LoadLibraryExW(fulldelayloadeddllpath, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR)
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
SetDllDirectoryW(L"C:\\myplugins");
LoadLibraryW(L"onnxruntime.dll");
k4abt::tracker::create()
Some interesting things to notice
The text was updated successfully, but these errors were encountered: