Wrong detected resource leak

delphi package - automated exception handling

Wrong detected resource leak

Postby MarcoNica » Fri Feb 16, 2018 12:38 pm

I'm using madExcept 4.0.19 and get a wrong report for a resource leak in the code below.
MadExcept reports a leaked region that was created in CreateRectRgnIndirect.
But windows will manage the release of the region because GetDCEx with the flag DCX_INTERSECTRGN was called.

Here a little summary from the Microsoft documentation for the GetDcEx call:
hrgnClip [in]
A clipping region that may be combined with the visible region of the DC. If the value of flags is DCX_INTERSECTRGN or DCX_EXCLUDERGN, then the operating system assumes ownership of the region and will automatically delete it when it is no longer needed. In this case, the application should not use or delete the region after a successful call to GetDCEx.



Code: Select all
var
  rgn: HRGN;
  dc: HDC;
  nullRect: TRect;
begin
  nullRect := Rect(0,0,0,0);
  rgn := CreateRectRgnIndirect(nullRect);
  dc := GetDCEx(Handle, rgn, DCX_PARENTCLIP or DCX_CLIPSIBLINGS or DCX_INTERSECTRGN);
  ReleaseDC(Handle, dc);
end;
MarcoNica
 
Posts: 2
Joined: Fri Feb 16, 2018 12:24 pm

Re: Wrong detected resource leak

Postby madshi » Fri Feb 16, 2018 2:52 pm

Good catch, thanks for letting me know! I'll fix this for the next build.
madshi
Site Admin
 
Posts: 9757
Joined: Sun Mar 21, 2004 5:25 pm

Re: Wrong detected resource leak

Postby MarcoNica » Mon Feb 19, 2018 7:38 am

Thank you for the fast replay.
MarcoNica
 
Posts: 2
Joined: Fri Feb 16, 2018 12:24 pm

Re: Wrong detected resource leak

Postby anders_g » Thu Apr 19, 2018 9:13 am

Any timeframe for next build?
/Anders
anders_g
 
Posts: 1
Joined: Wed Dec 27, 2017 7:56 am

Re: Wrong detected resource leak

Postby madshi » Thu May 17, 2018 11:56 am

I'm sorry for the delay in answering and fixing. I've now fixed this issue in my sources and the fix will be included in the next build, which I hope should be out later this week or early next week.
madshi
Site Admin
 
Posts: 9757
Joined: Sun Mar 21, 2004 5:25 pm

Re: Wrong detected resource leak

Postby pp » Thu May 24, 2018 7:52 am

^ Friendly bump. Do you have a timeframe?

I have some codes from DevExpress that MadExcept / resources is flagging resource errors.
pp
 
Posts: 3
Joined: Fri Dec 19, 2008 8:26 am

Re: Wrong detected resource leak

Postby madshi » Thu May 24, 2018 8:50 am

Sorry. You can use the latest beta build which (I think) has this fix included:

http://madshi.net/madCollectionBeta.exe

If not, let me know, then I'll recompile and upload a new build.
madshi
Site Admin
 
Posts: 9757
Joined: Sun Mar 21, 2004 5:25 pm

Re: Wrong detected resource leak

Postby pp » Sun May 27, 2018 5:02 am

1. nope, it still doesn't fix the error.

2. This error is critical / show-stopping error.

Reason: Lot of vendors - TMS, LMD, DevExpress use the above routine in their code.

3. I ship my app with madExcept turned on.

I get random errors, not related to MadExcept triggering from inside TMS, LMD and DevEx. The vendors say MadExcept is faulty, I state it's the vendor's code that's shoddy.

Personally I think the code is faulty and the vendor is lying about it - as this is show-stopping. My app crashes and the code-break-point is inside DevEx's code; then TMS, then LMD.

Either way, it's not going nice nor well. So, can you provide a fix for this?
If you need to contact me privately please state so, so this bug can be quickly resolved.
pp
 
Posts: 3
Joined: Fri Dec 19, 2008 8:26 am

Re: Wrong detected resource leak

Postby madshi » Mon May 28, 2018 3:21 pm

Argh, I uploaded the last beta build one day before I made this fix in my sources. So here's a new beta build which should now really fix the problem:

http://madshi.net/madCollectionBeta.exe (installer 2.8.4.11)

I don't understand why it would be a critical / show stopper error, though. Leak reporting is not supposed to be turned on all the time, because it eats lots of RAM and slows everything down. It's intended to be turned on only on the development PC, or maybe sometimes for a very specific test on a customer PC. Of course madExcept itself should (usually) be always active. But leak reporting is a completely separate part.

Actually, unless you manually distribute madExcept32.dll with your EXE file, leak reporting will be automatically disabled on your users' PCs. Leak reporting requires madExcept32.dll to be present. On your development PC madExcept automatically finds madExcept32.dll if madCollection is properly installed. On your end users' PCs usually madExcept32.dll is not present. So by default leak reporting should be disabled on your end users' PCs, even if you have it enabled on your development PC.

If you get random errors, they are very VERY unlikely to be caused by this "wrong detected resource leak". All this little bug does is report a leak which isn't really a leak. But this should not result in any random errors. Furthermore, as described above, leak reporting shouldn't be active on your end users' PCs, anyway. So the reason for those random errors is probably something completely different.

If your app crashes and the code-break-point is inside DevEx/TMS/LMD code, then why do you think this has anything to do with leak reporting? Does this problem go away if you disable leak reporting? What is the exact madExcept crash report you get from this situation?
madshi
Site Admin
 
Posts: 9757
Joined: Sun Mar 21, 2004 5:25 pm


Return to madExcept

Who is online

Users browsing this forum: No registered users and 3 guests

cron