LoadLibrary freezes
I have compiled a JNI dll that I would like to load into my Java application using System.loadLibrary
. This works perfectly fine on Windows XP with the dll compiled using MSVC++ 2008 Express.
However, on Windows 7, where I compiled the dll using MSVC++ 2010 Express (same options, same processor architecture, same Java version, just different OS and compiler) the application would freeze upon the loadLibrary
call. No error messages, no reaction at all. When I try jstack
on the frozen process it freezes as well (no output, no termination). Running the application as an administrator does not fix this problem.
The DLL and all its dependencies are in the java.library.path
. In fact, when I removed them, the Java application would tell me they're missing, so the dll must have been initialized properly and something else fails. Debugging proves, however, that it's actually loadLibrary
freezing and nothing afterwards.
Can anybody tell me what mi开发者_如何学Pythonght be going on here?
UPDATE:
As stated in my comment below, this problem seems to go deeper. Using a simple C program to load one of the dependencies of said DLL already makes the freeze occur, so this must be some kind of problem with the Windows API and how MSVC++ linked the DLL (that dependency was linked by MSVC++ 2010 Express as well).
Your DLL is almost certainly calling something that tries to obtain the loader lock from inside its DLLMain()
.
What you describe is called deadlock and these symptoms fit this particular issue perfectly.
精彩评论