Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-01

Second AV is not catched

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner

The below program has 2 try..except blocks. In each block an object is created, that gives an access violation.
The first is catched, the second not.
Why?

program ConstructorKill;
{$mode objfpc}{$H+}
uses
  Classes, SysUtils;
type
  { TMyObject }
  TMyObject = class(TObject)
  public
    constructor Create(TheOwner: TObject);
  end;

{ TMyObject }

constructor TMyObject.Create(TheOwner: TObject);
begin
  // create AV
  if TheOwner.ClassName='' then;
end;
begin
  writeln('Creating the first time');
  try
    TMyObject.Create(nil);
  except
    on E: Exception do begin
      writeln('E='+E.Message);
    end;
  end;
  writeln('Creating the second time');
  try
    TMyObject.Create(nil);
  except
    on E: Exception do begin
      writeln('E='+E.Message);
    end;
  end;
  writeln('Ending ..');
end.

Mattias

Reply by email

Peter Vreman
to Mattias Gaertner
The below program has 2 try..except blocks. In each block an object is created, that gives an access violation. The first is catched, the second not. Why?

Because the signal SIGSEGV is still blocked.

I'll fix it when i'm home.

Reply by email