Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Handle Leak when Compiling with /clr Option, and _beginthread.

Handle Leak when Compiling with /clr Option, and _beginthread.

Scheduled Pinned Locked Moved Managed C++/CLI
helpcsharpdotnetsysadminsecurity
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mike Doner
    wrote on last edited by
    #1

    Hi all, Hoping you can help me out. I've been trying to track down a handle leak in our product for the last few days, and I've gotten to the point where I suspect something is happening outside of our code. It seems that everytime my application calls _beginthread, there is 5 handles that leak. This happens to be our Server application, which receives many requests and calls to _beginthread, so after a period of time, this gets ugly. This application is compiled with /clr to use code written in a .DLL for LDAP Authentication. But regardless of whether nor not any C#/DLL code gets ran, we're still leaking. I commented EVERYTHING out, except a call to _beginthread. Inside the thread proc, all I do is call _endthread... And the problem still occurs - 5 handles on every call.. This is verified using Process Explorer and the WinDbg tool. If I turn off the /clr flag, and the problem goes away... I did a !htrace in WinDbg, and this is what its showing me.. Outstanding handles opened since the previous snapshot: -------------------------------------- Handle = 0x00000240 - OPEN Thread ID = 0x00003754, Process ID = 0x000038a4 0x77cb4210: ntdll!ZwCreateEvent+0x0000000c 0x7796b857: KERNEL32!CreateEventExW+0x0000006e 0x7796b8a6: KERNEL32!CreateEventW+0x00000027 0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027 0x72b21575: mscorwks!Thread::AllocHandles+0x0000009b 0x72b235e2: mscorwks!Thread::InitThread+0x000001a4 0x72b21f21: mscorwks!SetupThread+0x000002b2 0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019 0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b 0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048 0x0f59dbd3: MSVCR90D!_beginthread+0x00000233 0x0f59db6e: MSVCR90D!_beginthread+0x000001ce 0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e -------------------------------------- Handle = 0x0000023c - OPEN Thread ID = 0x00003754, Process ID = 0x000038a4 0x77cb4210: ntdll!ZwCreateEvent+0x0000000c 0x7796b857: KERNEL32!CreateEventExW+0x0000006e 0x7796b8a6: KERNEL32!CreateEventW+0x00000027 0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027 0x72b21569: mscorwks!Thread::AllocHandles+0x0000008f 0x72b235e2: mscorwks!Thread::InitThread+0x000001a4 0x72b21f21: mscorwks!SetupThread+0x000002b2 0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019 0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b 0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048 0x0f59dbd3: MSVCR90D!_beginthread+0x00000233 0x0f59db6e: MSVCR90D!_be

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups