Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Exceptions    [ Add a report in this area ]  
Report #:  106932   Status: Withdrawn
(Regression from Delphi 2010) Wrong exception handling for EExternalException (object leak and AV)
Project:  Delphi Build #:  16.0.4429.46931
Version:    16.4 Submitted By:   Alexander Alexeev
Report Type:  Basic functionality failure Date Reported:  7/5/2012 3:53:12 PM
Severity:    Serious / Highly visible problem Last Updated: 7/5/2012 5:19:20 PM
Platform:    All versions Internal Tracking #:  
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
There is a bug in exception handling code of Delphi RTL for x86-32 which result in:
A). Memory leak.
B). Access violation.

Consider this code:

  RaiseException(1, 0, 0, nil);

EExternalException object will be created for "RaiseException" call. However, it is not saved anywhere and will be lost. Instead, some trash values will be saved as Delphi object. This will cause AV later, when RTL will try to release exception object (AV will be raised by Free/Destroy call of TObject).

D7 - has no issue.
D2009 - has no issue.
D2010 - has no issue.
DXE - has issue.
DXE2 - has issue.

So, it seems that this behaviour was breaked during implementing cross-platform technologies in Delphi.

P.S. There is somehow similar issue that was fixed in the past: http://qc.embarcadero.com/wc/qcmain.aspx?d=3018
Steps to Reproduce:
1. Create new VCL project.
2. Place a button and add this code to OnClick:

  RaiseException(1, 0, 0, nil);

3a. Run application under debugger.
4a. Click on button.
Expected: 1 debugger exception notificatons and a message box with "External exception 1" message.
Actual: 2 debugger exception notifications (external exception + access violation), no message box.

3b. Run application outside of debugger.
4b. Click on button.
Expected: error message box with "External exception 1" message.
Actual: no error message box.



Reproduce with attached project:
1. Open attached project.
2. Be sure that "Use Debug DCUs" option is enabled.
3. Open System unit.
4. Find _HandleFinally routine for x86-32.
5. Place a breakpoint on 4th line - "PUSH    EBX".
6. Run the application and click on button.
7. Skip first debugger notification and wait for breakpoint hit.
8. Analyze exception record saved in EAX - it is wrong. See attached screenshot for more explanation.
Workarounds
None
Attachment
ExpBug.zip
Comments

None

Server Response from: ETNACODE01