Simple application to produce crash (Access Violation)
FastMM4 must be used in FullDebugMode
program CrashFastMM4;
uses
FastMM4,
Generics.Defaults;
type
IMyInterface = interface
['{DA9A7D06-C9D8-4220-9981-4E48EDC3CEEB}']
end;
TMyInterfaceImplementation = class(TSingletonImplementation, IMyInterface)
end;
TMyObject = class(TObject, IMyInterface)
private
FMyInterface: TMyInterfaceImplementation;
function GetMyInterface: TMyInterfaceImplementation;
public
constructor Create;
destructor Destroy; override;
property MyInterface: TMyInterfaceImplementation read GetMyInterface implements IMyInterface;
end;
constructor TMyObject.Create;
var I: IMyInterface;
begin
I:=Self;
end;
destructor TMyObject.Destroy;
begin
FMyInterface.Free;
inherited;
end;
function TMyObject.GetMyInterface: TMyInterfaceImplementation;
begin
if FMyInterface=nil then
FMyInterface:=TMyInterfaceImplementation.Create; // <-----------CrashPoint @ system._GetMem (MemoryManager.GetMem(Size));
Result:=FMyInterface;
end;
begin
TMyObject.Create.Free;
end.
Hi,
I've traced the crash to a Windows API call (CaptureStackBackTrace). At this point I suspect that the 64-bit compiler is doing something wrong with the stack frame setup, because I would not expect CaptureStackBackTrace to crash. I'll investigate further and open a QC report if need be.
Thanks,
Pierre
The following code also produces the crash (without FastMM4):
program x64InterfaceCrash;
{$APPTYPE CONSOLE}
uses
Vcl.Dialogs,
Generics.Defaults;
type
IMyInterface = interface
end;
TMyInterfaceImplementation = class(TSingletonImplementation, IMyInterface)
end;
TMyObject = class(TObject, IMyInterface)
private
FMyInterface: TMyInterfaceImplementation;
function GetMyInterface: TMyInterfaceImplementation;
public
constructor Create;
property MyInterface: TMyInterfaceImplementation read GetMyInterface implements IMyInterface;
end;
constructor TMyObject.Create;
var
I: IMyInterface;
begin
I := Self;
end;
function TMyObject.GetMyInterface: TMyInterfaceImplementation;
var
LStackTrace: Pointer;
begin
ShowMessage('This crashes under x64.');
Result := nil;
end;
begin
TMyObject.Create;
end.