opendnssec / SoftHSMv2

SoftHSM version 2
http://www.softhsm.org/
Other
780 stars 343 forks source link

SoftHSM2 error in Windows event log #598

Open justincranford opened 3 years ago

justincranford commented 3 years ago

This SoftHSM2 error in Windows event viewer is causing a problem for me. c:\build\src\softhsm-2.5.0-x64\src\lib\common\osmutex.cpp(177): Failed to destroy WIN32 mutex (0x00000006)

I am running a Gradle integration test job. It runs Java 11.0.9.1 with tests that use Java SunPKCS11 provider with C:\SoftHSM2\lib\softhsm2-x64.dll. All of my PKCS#11 tests pass, but the job exits with a warning. Process 'Gradle Test Executor 1' finished with non-zero exit value -1073740791

Gradle seems to be detecting a problem with the native library not shutting down OK. That is what led me to find the SoftHSM2 error in Windows event viewer.

Why would a "Failed to destroy WIN32 mutex" error be happening?

Note, I am using a SoftHSM2 v2.5.0 for Windows build from here.

I see newer 2.6.0 and 2.6.1 versions on opendnssec.org, but they are Linux downloads. I don't see any Windows downloads.

I would be willing to try latest SoftHSM2 for Windows if a build is available. I would also be willing to try extra debug logging if that is possible too. Note, I turned on DEBUG logging in C:\SoftHSM2\etc\softhsm2.conf but all I see is verbose INFO messages.

justincranford commented 3 years ago

Here is a good example of Gradle returning same error I got. Reason is a DLL failed to unload cleanly.

https://gaming.stackexchange.com/questions/299218/minecraft-crashing-with-message-game-ended-with-bad-state-exit-code-107374079

[13:53:40 INFO]: Looking for old natives & assets to clean up...
[13:53:48 ERROR]: Game ended with bad state (exit code -1073740791)

This is why I think SoftHSM2 is failing to unload cleanly, and Gradle is just detecting the issue and reporting it via return code -1073740791.

rijswijk commented 3 years ago

The build for Windows is maintained in the separate project you refer to, and we currently have no capacity to actively test SoftHSM on Windows I'm afraid. The logged value is the DWORD return value returned by the call to CloseHandle(..). As far as I can see, this return code means "handle invalid". The first place I would look to diagnose this problem is the shutdown sequence of the executable. Perhaps some cleanup code that is called before SoftHSM performs its cleanup sequence already invalidates all open mutex handles.

Maybe @jariq has suggestions? He is more of a Windows dev expert than I am.

jariq commented 3 years ago

No suggestions from my side.