In my C++ application, I have added CLR support((/clr) to use WCF communication. Everything is working well, but i observed handle leak. When I analyze this with WinDbg(!htrace). Its shows handle leaks in .NET libs as shown below. Handle = 0x0000000000003300 - OPEN Thread ID = 0x0000000000004dbc, Process ID = 0x000000000000414c 0x000000007785a30a: ntdll!ZwCreateThreadEx+0x000000000000000a 0x000007fefd37ac73: KERNELBASE!CreateRemoteThreadEx+0x0000000000000163 0x00000000776e57a6: KERNEL32!CreateThread+0x0000000000000036 0x000007fedaf3f0aa: clr!ClrCreateManagedInstance+0x000000000001ae0a 0x000007fedaf3efb8: clr!ClrCreateManagedInstance+0x000000000001ad18 0x000007fedaf3f5e3: clr!ClrCreateManagedInstance+0x000000000001b343 0x000007fedaf3f623: clr!ClrCreateManagedInstance+0x000000000001b383 0x000007fedaeb3b5e: clr!PreBindAssemblyEx+0x0000000000007e5e 0x000007fedae0a05f: clr!LogHelp_LogAssert+0x000000000000525f 0x000007fedae0837c: clr!LogHelp_LogAssert+0x000000000000357c 0x000007fedae08125: clr!LogHelp_LogAssert+0x0000000000003325 -------------------------------------- Handle = 0x00000000000032fc - OPEN Thread ID = 0x0000000000004dbc, Process ID = 0x000000000000414c 0x0000000077859d0a: ntdll!ZwCreateEvent+0x000000000000000a 0x000007fefd372d15: KERNELBASE!CreateEventExW+0x0000000000000065 0x000007fedaf3db8a: clr!ClrCreateManagedInstance+0x00000000000198ea 0x000007fedaf3dd27: clr!ClrCreateManagedInstance+0x0000000000019a87 0x000007fedaf3f077: clr!ClrCreateManagedInstance+0x000000000001add7 0x000007fedaf3efb8: clr!ClrCreateManagedInstance+0x000000000001ad18 0x000007fedaf3f5e3: clr!ClrCreateManagedInstance+0x000000000001b343 0x000007fedaf3f623: clr!ClrCreateManagedInstance+0x000000000001b383 0x000007fedaeb3b5e: clr!PreBindAssemblyEx+0x0000000000007e5e 0x000007fedae0a05f: clr!LogHelp_LogAssert+0x000000000000525f 0x000007fedae0837c: clr!LogHelp_LogAssert+0x000000000000357c 0x000007fedae08125: clr!LogHelp_LogAssert+0x0000000000003325 0x000007fedaeb5abf: clr!PreBindAssemblyEx+0x0000000000009dbf 0x00000000776e571d: KERNEL32!BaseThreadInitThunk+0x000000000000000d -------------------------------------- Handle = 0x00000000000032f8 - OPEN Thread ID = 0x0000000000004dbc, Process ID = 0x000000000000414c 0x0000000077859d0a: ntdll!ZwCreateEvent+0x000000000000000az 0x000007fefd372d15: KERNELBASE!CreateEventExW+0x0000000000000065 0x000007fedaf3db8a: clr!ClrCreateManagedInstance+0x00000000000198ea 0x000007fedaf3dd19: clr!ClrCreateManagedInstance+0x0000000000019a79 0x000007fedaf3f077: clr!ClrCr
atm menon
Posts
-
Handle leak in application complied with CLR option. -
GetWindowRgn API returns ERRORhi, GetLastError shows 6, ie. invalid handle. But when i call method again after failure occurs, its works fine :( I have workarounds for the problem. But I am curious to know the reason. why its happened only some times even if dialog have region. Thanks in advance Arun
-
GetWindowRgn API returns ERRORIn My application, I have used the following code to get the region of a dialog.
HRGN hRgn = CreateRectRgn( 0, 0, 0, 0 );
int nRet = GetWindowRgn( hRgn );
if(ERROR == nRet)
{
DWORD dw= GetLastError();
//Log
}The problem is that, sometimes "GetWindowRgn" returns error "invalid handle" even if CreateRectRgn returns a non-null handle which is used for GetWindowRgn. I have set the region in onSize(). So dialog have region.Also after GetWindowRgn returns error, when i call GetWindowRgn() again, second call is working fine !!! Issue is reproduced only sometimes in a Windows 7 machine. Anyone already faced similar issue? Thanks, Arun
-
GetWindowRgn API is failed.In My application, I have used the following code to get the region of a dialog.
HRGN hRgn = CreateRectRgn( 0, 0, 0, 0 );
int nRet = GetWindowRgn( hRgn );
if(ERROR == nRet)
{
DWORD dw= GetLastError();
//Log
}The problem is that, sometimes "GetWindowRgn" returns error "invalid handle" even if CreateRectRgn returns a non-null handle which is used for GetWindowRgn. I have set the region in onSize(). So dialog have region.Also after GetWindowRgn returns error, when i call GetWindowRgn() again, second call is working fine !!! Issue is reproduced only sometimes in a Windows 7 machine. Anyone already faced similar issue? Thanks, Arun
-
WNetGetConnection API behaves wrongly when UAC is enabledHi, Thanks for your reply. Hmm.. I have just shared the folder( permission to everyone i think). The problem is still exists when UAC is enabled( my UAC settings is default) and I run application as admin. Its works fine when UAC is disabled( i.e Never notify). Thanks Arun
-
WNetGetConnection API behaves wrongly when UAC is enabledHi, I am using WNetGetConnection() API to check that my network drive(mapped to a local share folder) is connected or not. When i run this application as run as administrator with UAC enabled, this API return success even if n/w drive is disconnected. Its works fine when i run application without admin privilege( standard user). Anybody got the same issue? Any help or guidance would be appreciated. Sample code
LPTSTR lpszDeviceName = 0;
lpszDeviceName = new TCHAR[ 256];
DWORD dwcchBuff = MAX_PATH;
DWORD dwResult = 0;
dwResult = WNetGetConnection( _T("Z:"), lpszDeviceName, &dwcchBuff );
if( NO_ERROR != dwResult )
{
printf("Media removed\n");
}
else
{
printf("Media inserted\n");
}