Delphi 2009: How do I prevent network application from leaking critical section?

Posted by eed3si9n on Stack Overflow See other posts from Stack Overflow or by eed3si9n
Published on 2010-05-12T12:43:31Z Indexed on 2010/05/12 17:14 UTC
Read the original article Hit count: 466

As part of Vista certification, Microsoft wants to make sure that an application exits without holding on to a lock (critical section):

TEST CASE 31. Verify application does not break into a debugger with the specified AppVerifier checks (Req:3.2)

As it turns out, network applications built using Delphi 2009 does break into the debugger, which displays unhelpful message as follows:

(1214.1f10): Break instruction exception - code 80000003 (first chance)
eax=00000001 ebx=07b64ff8 ecx=a6450000 edx=0007e578 esi=0017f7e0 edi=80000003
eip=77280004 esp=0017f780 ebp=0017f7ac iopl=0         nv up ei pl zr na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000246
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Windows\SysWOW64\ntdll.dll - 
ntdll!DbgBreakPoint:
77280004 cc              int     3

After hitting Go button several times, you come across the actual error:

=======================================
VERIFIER STOP 00000212: pid 0x18A4: Freeing virtual memory containing an active critical section. 

    076CC5DC : Critical section address.
    01D0191C : Critical section initialization stack trace.
    075D0000 : Memory block address.
    00140000 : Memory block size.


=======================================
This verifier stop is continuable.
After debugging it use `go' to continue.

=======================================

Given that my code does not leak TCriticalSection, how do I prevent Delphi from doing so.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about delphi-2009