Page 1 of 1

AV in MadExcept32.dll

PostPosted: Mon Aug 06, 2012 8:54 am
by BugDigger
Hi Mathias!

I have a problem with latest version.
CB2007. Nearly empty test VCL application with the only button:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
try
{
int* p =(int*)12345;
int w = *p; // try read, invalid access
}
catch(EAccessViolation& e) { ShowMessage("caught in AV"); }
catch (Exception& e) { ShowMessage("caught in Ex"); }
catch(...) { ShowMessage("caught in ..."); }
}

1) run and close the application without pressing button - OK, no problem
2) run. press button (AV and message box as expected). Close application - AV in MadExcept32.dll.

I see no saved bug report, so I send screenshort in attachment.

Re: AV in MadExcept32.dll

PostPosted: Mon Aug 06, 2012 12:27 pm
by madshi
Hello,

I've tried to reproduce the problem on my PC, but it doesn't occur here. Could you please email your project to me with full source code and your compiled exe file?

Thanks, Mathias.

Re: AV in MadExcept32.dll

PostPosted: Tue Aug 07, 2012 3:59 am
by BugDigger
See test project in attachment.

Umm... Attachment is downloaded (as I can see in browser's progress bar) but I don't see any visual mark about presence of the attachment...

Re: AV in MadExcept32.dll

PostPosted: Tue Aug 07, 2012 4:19 am
by BugDigger
madshi wrote:I've tried to reproduce the problem on my PC, but it doesn't occur here.


BTW, it can be related to the problem (crash after "unoffending" AV) discussed on

https://forums.embarcadero.com/thread.j ... t=0#478749

http://blogs.msdn.com/b/oldnewthing/arc ... 73741.aspx

But initial AV in the test project is on address 12345 which can not be stack guard page.

Re: AV in MadExcept32.dll

PostPosted: Tue Aug 07, 2012 1:13 pm
by madshi
I don't think it's related to that.

I don't see any attachments, either. Could you please email the project (with compiled exe) to me? madshi (at) gmail (dot) com. Thanks.

Re: AV in MadExcept32.dll

PostPosted: Wed Aug 08, 2012 2:21 am
by BugDigger
Done. Archive's password is "AVtest" (gmail rejects exe in attachment).

Re: AV in MadExcept32.dll

PostPosted: Thu Aug 09, 2012 10:26 am
by madshi
Thanks, that was quite helpful. The problem should be fixed in this build:

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

Could you please confirm?

Re: AV in MadExcept32.dll

PostPosted: Fri Aug 10, 2012 9:09 am
by BugDigger
Hello, Mathias!
Yes, now all work as expected, thank you!

But what do you think about the results? (see attached generated leak report; 2 AV after 2 button click)
1) Expert shows memory leak on every AV in test. Is this really memory leak? What about newer versions of CB?
2) Why report shows call stack from TApplication.ProcessMessage (not my button click procedure)?

Re: AV in MadExcept32.dll

PostPosted: Fri Aug 10, 2012 9:12 am
by BugDigger
I don't see my attachment again. Here is its contents:

Code: Select all
Project3.exe - 2012-08-10 - 15.55.01 - leak report.mbr

allocation number: 1901
program up time: 2.42 s
type: EAccessViolation
address: $4ec8ff0
size: 16
access rights: read/write
message: EAccessViolation

main thread ($b38):
671c9455 madExcept32.dll madExceptDbg  1442 GetMemCallback
0040726c Project3.exe    system        2654 @GetMem
0040840a Project3.exe    system        8807 TObject.NewInstance
004935b6 Project3.exe                       __ClassCreate
00497ea6 Project3.exe    Sysutils           EAccessViolation.Create
00495d15 Project3.exe    Controls           TWinControl.GetDeviceContext
0040ea77 Project3.exe    madExcept          _16526
00498452 Project3.exe                       ____ExceptionHandler
0049fc5d Project3.exe    Sysutils           @__InitExceptBlockLDTC
7c90e485 ntdll.dll                          KiUserExceptionDispatcher
004751fc Project3.exe    Controls      5229 TControl.Click
004956e2 Project3.exe    stdctrls      3745 TButton.Click
004957e0 Project3.exe    stdctrls      3797 TButton.CNCommand
00474cf7 Project3.exe    Controls      5146 TControl.WndProc
00478cef Project3.exe    Controls      7304 TWinControl.WndProc
0049558c Project3.exe    stdctrls      3684 TButtonControl.WndProc
00474984 Project3.exe    Controls      5021 TControl.Perform
00478e3f Project3.exe    Controls      7353 DoControlMsg
00479837 Project3.exe    Controls      7616 TWinControl.WMCommand
0048a588 Project3.exe    forms         5016 TCustomForm.WMCommand
00474cf7 Project3.exe    Controls      5146 TControl.WndProc
00478cef Project3.exe    Controls      7304 TWinControl.WndProc
00487677 Project3.exe    forms         3512 TCustomForm.WndProc
00478418 Project3.exe    Controls      7073 TWinControl.MainWndProc
0046d4c0 Project3.exe    Classes      11583 StdWndProc
7c90e470 ntdll.dll                          KiUserCallbackDispatcher
7e3792de USER32.dll                         SendMessageW
7e37a993 USER32.dll                         CallWindowProcA
00478deb Project3.exe    Controls      7334 TWinControl.DefaultHandler
00478cef Project3.exe    Controls      7304 TWinControl.WndProc
0049558c Project3.exe    stdctrls      3684 TButtonControl.WndProc
0046d4c0 Project3.exe    Classes      11583 StdWndProc
7e3696c2 USER32.dll                         DispatchMessageA
0048f3f4 Project3.exe    forms         8105 TApplication.ProcessMessage

memory dump:
04ec8ff0  d0 97 49 00 ec af ec 04 - 00 00 00 00 00 00 00 00  ..I.............

allocation number: 1996
program up time: 6.77 s
type: EAccessViolation
address: $5758ff0
size: 16
access rights: read/write
message: EAccessViolation

main thread ($b38):
671c9455 madExcept32.dll madExceptDbg  1442 GetMemCallback
0040726c Project3.exe    system        2654 @GetMem
0040840a Project3.exe    system        8807 TObject.NewInstance
004935b6 Project3.exe                       __ClassCreate
00497ea6 Project3.exe    Sysutils           EAccessViolation.Create
00495d15 Project3.exe    Controls           TWinControl.GetDeviceContext
0040ea77 Project3.exe    madExcept          _16526
00498452 Project3.exe                       ____ExceptionHandler
0049fc5d Project3.exe    Sysutils           @__InitExceptBlockLDTC
7c90e485 ntdll.dll                          KiUserExceptionDispatcher
004751fc Project3.exe    Controls      5229 TControl.Click
004956e2 Project3.exe    stdctrls      3745 TButton.Click
004957e0 Project3.exe    stdctrls      3797 TButton.CNCommand
00474cf7 Project3.exe    Controls      5146 TControl.WndProc
00478cef Project3.exe    Controls      7304 TWinControl.WndProc
0049558c Project3.exe    stdctrls      3684 TButtonControl.WndProc
00474984 Project3.exe    Controls      5021 TControl.Perform
00478e3f Project3.exe    Controls      7353 DoControlMsg
00479837 Project3.exe    Controls      7616 TWinControl.WMCommand
0048a588 Project3.exe    forms         5016 TCustomForm.WMCommand
00474cf7 Project3.exe    Controls      5146 TControl.WndProc
00478cef Project3.exe    Controls      7304 TWinControl.WndProc
00487677 Project3.exe    forms         3512 TCustomForm.WndProc
00478418 Project3.exe    Controls      7073 TWinControl.MainWndProc
0046d4c0 Project3.exe    Classes      11583 StdWndProc
7c90e470 ntdll.dll                          KiUserCallbackDispatcher
7e3792de USER32.dll                         SendMessageW
7e37a993 USER32.dll                         CallWindowProcA
00478deb Project3.exe    Controls      7334 TWinControl.DefaultHandler
00478cef Project3.exe    Controls      7304 TWinControl.WndProc
0049558c Project3.exe    stdctrls      3684 TButtonControl.WndProc
0046d4c0 Project3.exe    Classes      11583 StdWndProc
7e3696c2 USER32.dll                         DispatchMessageA
0048f3f4 Project3.exe    forms         8105 TApplication.ProcessMessage

memory dump:
05758ff0  d0 97 49 00 ec af 75 05 - 00 00 00 00 00 00 00 00  ..I...u.........

Re: AV in MadExcept32.dll

PostPosted: Fri Aug 10, 2012 1:18 pm
by madshi
It appears to be a real memory leak. I don't know why BCB doesn't properly release the exception object. Probably a bug in the RTL.

When an exception occurs in BCB, there's a lot of damage being done to the stack. In Delphi that's quite different. Stack tracing involves a lot of guessing (at least in x86 processes), as a result it can happen that there are missing or too many stack items in a callstack. With BCB, the danger is even higher than with Delphi.

Re: AV in MadExcept32.dll

PostPosted: Sat Aug 11, 2012 7:54 am
by BugDigger
Many thanks for information.

Could you please check this memory leak in XE2 (I have not this version of studio)?
If the problem still exists in the latest version it would be nice to file QC report on it to have a chance for fix in the next version.

Re: AV in MadExcept32.dll

PostPosted: Mon Aug 13, 2012 8:43 am
by madshi
Just checked. The leak seems to be fixed in BCB 2009 (and all newer versions).

Re: AV in MadExcept32.dll

PostPosted: Mon Aug 13, 2012 9:48 am
by BugDigger
OK, thank you for information.