When called from an atexit() function OpenSCManager may fail on Windows 2008 R2 with the following exception stack trace:
(608.129c): Access violation - code c0000005 (!!! second chance !!!)
SspiCli!CallSPM+0x26:
000007fe`fced16a2 488b4918 mov rcx,qword ptr [rcx+18h] ds:00000000`022fbfe8=????????????????
Child-SP RetAddr Call Site
00000000`001217e0 000007fe`fced4fb5 SspiCli!CallSPM+0x26
00000000`00121810 000007fe`fced4c2f SspiCli!SecpGetBinding+0xa3
00000000`00121a40 000007fe`fced4a92 SspiCli!SecpLoadLsaPackages+0xb3
00000000`00121b50 000007fe`fced1604 SspiCli!SecpLocatePackageEx+0x127
00000000`00121ba0 000007fe`fced426d SspiCli!SecLocatePackageById+0x34
00000000`00121bf0 000007fe`ff294f9e SspiCli!EnumerateSecurityPackagesW+0x21
00000000`00121c20 000007fe`ff278ed1 RPCRT4!FindSecurityPackage+0x20c
00000000`00121c90 000007fe`ff29347f RPCRT4!SECURITY_CREDENTIALS::AcquireCredentialsForClient+0x51
00000000`00121d50 000007fe`ff29d647 RPCRT4!BINDING_HANDLE::SetAuthInformation+0x19f
00000000`00121dd0 000007fe`fee6b8a9 RPCRT4!RpcBindingSetAuthInfoExW+0x1a7
00000000`00121ec0 000007fe`fee6b3b7 sechost!ScClientBindToServerUsingTCP+0x365
00000000`00121f90 000007fe`fee6b0a2 sechost!ScClientBindToServer+0x287
00000000`001220a0 000007fe`ff2bad10 sechost!SVCCTL_HANDLEW_bind+0xe
00000000`001220d0 000007fe`ff34fe74 RPCRT4!GenericHandleMgr+0x88
00000000`00122100 000007fe`ff350c0d RPCRT4!NdrpClientCall2+0xa79
00000000`00122870 000007fe`fee66609 RPCRT4!NdrClientCall2+0x1d
00000000`001228a0 00000000`03e4b78b sechost!OpenSCManagerW+0x6d
(608.129c): Access violation - code c0000005 (!!! second chance !!!)
SspiCli!CallSPM+0x26:
000007fe`fced16a2 488b4918 mov rcx,qword ptr [rcx+18h] ds:00000000`022fbfe8=????????????????
Child-SP RetAddr Call Site
00000000`001217e0 000007fe`fced4fb5 SspiCli!CallSPM+0x26
00000000`00121810 000007fe`fced4c2f SspiCli!SecpGetBinding+0xa3
00000000`00121a40 000007fe`fced4a92 SspiCli!SecpLoadLsaPackages+0xb3
00000000`00121b50 000007fe`fced1604 SspiCli!SecpLocatePackageEx+0x127
00000000`00121ba0 000007fe`fced426d SspiCli!SecLocatePackageById+0x34
00000000`00121bf0 000007fe`ff294f9e SspiCli!EnumerateSecurityPackagesW+0x21
00000000`00121c20 000007fe`ff278ed1 RPCRT4!FindSecurityPackage+0x20c
00000000`00121c90 000007fe`ff29347f RPCRT4!SECURITY_CREDENTIALS::AcquireCredentialsForClient+0x51
00000000`00121d50 000007fe`ff29d647 RPCRT4!BINDING_HANDLE::SetAuthInformation+0x19f
00000000`00121dd0 000007fe`fee6b8a9 RPCRT4!RpcBindingSetAuthInfoExW+0x1a7
00000000`00121ec0 000007fe`fee6b3b7 sechost!ScClientBindToServerUsingTCP+0x365
00000000`00121f90 000007fe`fee6b0a2 sechost!ScClientBindToServer+0x287
00000000`001220a0 000007fe`ff2bad10 sechost!SVCCTL_HANDLEW_bind+0xe
00000000`001220d0 000007fe`ff34fe74 RPCRT4!GenericHandleMgr+0x88
00000000`00122100 000007fe`ff350c0d RPCRT4!NdrpClientCall2+0xa79
00000000`00122870 000007fe`fee66609 RPCRT4!NdrClientCall2+0x1d
00000000`001228a0 00000000`03e4b78b sechost!OpenSCManagerW+0x6d