PDA

View Full Version : App hangs when exception forced


blacky
17-Dec-2008, 10:45 AM
Using Eurekalog 6.0.18 Enterprise.
App is running in the IDE.
Delphi 2009 Update 1.

The sample code below deliberately triggers two exceptions: "Exception A" and "Exception B".
Exception A is caught by Eurekalog and all the appropriate reporting is performed correctly.
However, comment out "Exception A" so that "Exception X" is triggered and Eurekalog does not report the exception. The app appears to just hang.

Sample code:
unit Main_Except;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, xmldom, XMLIntf, msxmldom, XMLDoc;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure ParseXml(aFileName: string);
procedure ParseNode(node: IXMLNode);
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

// __________________________________________________ _______________________
procedure TForm1.Button1Click(Sender: TObject);
begin
ParseXml('test.xml');
end;

// __________________________________________________ _______________________
procedure TForm1.ParseXml(aFileName: string);
var
xml: TXMLDocument;
begin
xml := TXMLDocument.Create(nil);
try
xml.FileName := '.\'+aFileName;
xml.Active := true;
Raise Exception.Create('Exception A');
ParseNode(xml.DocumentElement);
finally
FreeAndNil(xml);
end;
end;

// __________________________________________________ _______________________
procedure TForm1.ParseNode(node: IXMLNode);
begin
Raise Exception.Create('Exception X');
end;

end.

Environment (generated when "exception A" was triggered):
Computer:
--------------------------------------------------------------------------------
5.1 Name : xxxxxxxx
5.2 Total Memory : 2046 Mb
5.3 Free Memory : 932 Mb
5.4 Total Disk : 298.08 Gb
5.5 Free Disk : 57.1 Gb
5.6 System Up Time: 32 minutes, 14 seconds
5.7 Processor : Intel(R) Core(TM)2 CPU 6700 @ 2.66GHz
5.8 Display Mode : 1680 x 1050, 32 bit
5.9 Display DPI : 96
5.10 Video Card : NVIDIA GeForce 8600 GTS (driver 7.15.11.5824 - RAM 256 MB)
5.11 Printer : KONICA MINOLTA magicolor2300W (driver 5,51,0,0)

Operating System:
---------------------------------------
6.1 Type : Microsoft Windows Vista
6.2 Build # : 6001
6.3 Update : Service Pack 1
6.4 Language: English
6.5 Charset : 0

Network:
---------------------------------------------------------------------
<snip>

Call Stack Information:
------------------------------------------------------------------------------
|Address |Module |Unit |Class |Procedure/Method |Line |
------------------------------------------------------------------------------
|*Exception Thread: ID=5544; Priority=0; Class=; [Main] |
|----------------------------------------------------------------------------|
|004E27B9|Exceptions.exe|Main_Except.pas|TForm1|Pa rseXml |43[5]|
|004E273C|Exceptions.exe|Main_Except.pas|TForm1|Pa rseXml |38[0]|
|004E2715|Exceptions.exe|Main_Except.pas|TForm1|Bu tton1Click |31[1]|
|7758F6B1|USER32.dll | | |GetWindowLongW | |
|77668502|ntdll.dll | | |NtFindAtom | |
|773B5C9A|GDI32.dll | | |DeleteObject | |
|77590AF5|USER32.dll | | |SendMessageW | |
|77590697|USER32.dll | | |CallWindowProcW | |
|77590681|USER32.dll | | |CallWindowProcW | |
|77657D80|ntdll.dll | | |RtlLeaveCriticalSection| |
|7757E001|USER32.dll | | |GetCapture | |
|7759005B|USER32.dll | | |DispatchMessageW | |
|77590051|USER32.dll | | |DispatchMessageW | |
|004E3A39|Exceptions.exe|Exceptions.dpr | | |14[4]|
|7703490F|kernel32.dll | | |BaseThreadInitThunk | |
------------------------------------------------------------------------------

admin
17-Dec-2008, 02:47 PM
Hi blacky,

do you have tried the last 6.0.19 RC 2?

Unregistered
17-Dec-2008, 08:29 PM
I Just downloaded and installed 6.0.19 RC 2. The problem is exactly the same in that release as well.

Regards
Paul

blacky
17-Dec-2008, 08:34 PM
I also just tried the same thing under Delphi 2007 and the problem is exactly the same in D2007 as well.
Regards
Paul

blacky
17-Dec-2008, 08:53 PM
If line 39: # xml := TXMLDocument.Create(nil);
is changed to: # xml := TXMLDocument.Create(self);
Then EL correctly catches and handles "Exception X".

Regards
Paul

blacky
22-Dec-2008, 09:07 AM
Is there likely to be a fix for this?
Is it something that needs fixing in EL or am I overlooking something obvious?

Regards
Paul

admin
30-Dec-2008, 04:44 PM
Hi Paul,

this behavior it's a bit strange.

Can you create and send to me a little source demo able to reproduce this issue, please?

Karl
02-Jan-2009, 11:58 AM
I think it should be using an interface when created at runtime:


var
xml: IXMLDocument;


There is a good chance an AV is being raised though why that is not caught is odd.

blacky
05-Jan-2009, 03:39 AM
Hi Paul,

this behavior it's a bit strange.

Can you create and send to me a little source demo able to reproduce this issue, please?

The sample code I posted is a standalone app that you can compile and run and it reproduces the "problem".

Regards
Paul

blacky
05-Jan-2009, 03:41 AM
Hi Paul,

this behavior it's a bit strange.

Can you create and send to me a little source demo able to reproduce this issue, please?

Also, see my earlier post #5.

Regards
Paul

Karl
05-Jan-2009, 10:19 AM
Also, see my earlier post #5.

Hi Paul, have look at the CodeGear topic Strange access violations when using TXMLDocument at runtime (http://dn.codegear.com/article/29241), it should be using the interface IXMLDocument. I'll have a look later today as to what is happening with D2007/9 as Delphi7 does not exhibit this behaviour.

I assume the reference is being deleted before ParseXML is reached and an AV is being raised that is causing the application freeze.

admin
07-Jan-2009, 08:48 AM
Hi Karl,

yes, I think this can be the possible cause!