Delphi 2010: [DCC Fatal Error] F2084 Internal Error: AV00000000-R00000000-0

I'm trying to compile the following code but the compiler gives me an 
internal error message. This is my second experiment with generics and 
it is complete failure. Do they work at all? I'm very disappointed.

Checking project dependencies...
Compiling Multicast.dproj (Debug configuration)
[DCC Fatal Error] Multicast.dpr(152): F2084 Internal Error: 
AV00000000-R00000000-0
Failed
Elapsed time: 00:00:00.2

I have posted the project (a simple console application) to the 
attachments group.

Can anybody compile this code in their Delphi XE IDE?

program Multicast;
{$APPTYPE CONSOLE}

uses
	SysUtils;

type
	TEventHandler<TSenderType, TEventArgsType> = procedure(const aSender: 
TSenderType; const aEventArgs: TEventArgsType) of object;

	TEventHandlerContainer<TSenderType, TEventArgsType> = class(TObject)
	strict private
		FHandlers:array of TEventHandler<TSenderType, TEventArgsType>;

		function IndexOfHandler(const aHandler: TEventHandler<TSenderType, 
TEventArgsType>):Integer;
		function GetFirstFreeIndex:Integer;
	public
		destructor Destroy; override;

		procedure Add(const aHandler: TEventHandler<TSenderType, TEventArgsType>);
		procedure Remove(const aHandler: TEventHandler<TSenderType, 
TEventArgsType>);
		procedure Invoke(const aSender: TSenderType; const aEventArgs: 
TEventArgsType);
	end;

	TSimpleEventArgs=class(TObject)
	strict private
		FData:string;
	public
		constructor Create(const aData:string);
		property Data:string read FData;
	end;

	TSimpleHandler=TEventHandler<TObject, TSimpleEventArgs>;

	TSimpleEventHandlerContainer=class(TEventHandlerContainer<TObject, 
TSimpleEventArgs>);

	TSimpleListener1=class(TObject)
	public
		procedure EventHandler(const aSender:TObject; const 
aEventArgs:TSimpleEventArgs);
	end;

{ TEventHandlerContainer<TSenderType, TEventArgsType> }

procedure TEventHandlerContainer<TSenderType, TEventArgsType>.Add(const 
aHandler: TEventHandler<TSenderType, TEventArgsType>);
var
	HandlerIndex:Integer;
begin
	HandlerIndex:=GetFirstFreeIndex;
	if HandlerIndex>=Length(FHandlers) then
		SetLength(FHandlers, Length(FHandlers)+1);
	FHandlers[HandlerIndex]:=aHandler;
end;

destructor TEventHandlerContainer<TSenderType, TEventArgsType>.Destroy;
begin
	SetLength(FHandlers, 0);
	inherited;
end;

function TEventHandlerContainer<TSenderType, 
TEventArgsType>.GetFirstFreeIndex: Integer;
var
	idxHandler:Integer;
begin
	if Length(FHandlers)<1 then
		Result:=0
	else
	begin
		Result:=0;
		while (Result<Length(FHandlers)) and (@FHandlers[Result]<>nil) do
			Inc(Result);
	end;
end;

function TEventHandlerContainer<TSenderType, 
TEventArgsType>.IndexOfHandler(const aHandler: 
TEventHandler<TSenderType, TEventArgsType>): Integer;
var
	idxHandler:Integer;
begin
	Result:=-1;
	for idxHandler := Low(FHandlers) to High(FHandlers) do
	begin
		if @FHandlers[idxHandler]=@aHandler then
		begin
			Result:=idxHandler;
			Break;
		end;
	end;
end;

procedure TEventHandlerContainer<TSenderType, 
TEventArgsType>.Invoke(const aSender: TSenderType; const aEventArgs: 
TEventArgsType);
var
	idxHandler:Integer;
begin
	for idxHandler := Low(FHandlers) to High(FHandlers) do
		FHandlers[idxHandler](aSender, aEventArgs);
end;

procedure TEventHandlerContainer<TSenderType, 
TEventArgsType>.Remove(const aHandler: TEventHandler<TSenderType, 
TEventArgsType>);
var
	HandlerIndex:Integer;
begin
	HandlerIndex:=IndexOfHandler(aHandler);
	if HandlerIndex>=0 then
		FHandlers[HandlerIndex]:=nil;
end;

{ TSimpleEventArgs }

constructor TSimpleEventArgs.Create(const aData: string);
begin
	inherited Create;
	FData:=aData;
end;

{ TSimpleListener1 }

procedure TSimpleListener1.EventHandler(const aSender: TObject; const 
aEventArgs: TSimpleEventArgs);
begin
	WriteLn(ClassName+': '+aSender.ClassName+', '+aEventArgs.Data);
end;

var
	EventHandlerContainer:TEventHandlerContainer<TObject, TSimpleEventArgs>;
	Listener1:TSimpleListener1;
	EventArgs:TSimpleEventArgs;

begin
	try
		Listener1:=TSimpleListener1.Create;
		try
			EventHandlerContainer:=TSimpleEventHandlerContainer.Create;
			try
				EventHandlerContainer.Add(Listener1.EventHandler);
				try
					EventArgs:=TSimpleEventArgs.Create('Hello');
					try
						EventHandlerContainer.Invoke(EventHandlerContainer, EventArgs);
					finally
						FreeAndNil(EventArgs);
					end;
				finally
					EventHandlerContainer.Remove(Listener1.EventHandler);
				end;
			finally
				FreeAndNil(EventHandlerContainer);
			end;
		finally
			FreeAndNil(Listener1);
		end;
	except
		on E: Exception do
			Writeln(E.ClassName, ': ', E.Message);
	end;
end.
0
Andrew
9/16/2010 1:16:28 PM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

9 Replies
1379 Views

Similar Articles

[PageSpeed] 35

Andrew Fionik wrote:

> I'm trying to compile the following code but the compiler gives me an 
> internal error message. This is my second experiment with generics
> and it is complete failure. Do they work at all? I'm very
> disappointed.

Generics do work and a lot of people use them and like them, but
unfortunately there are still a few issues with them.

> Checking project dependencies...
> Compiling Multicast.dproj (Debug configuration)
> [DCC Fatal Error] Multicast.dpr(152): F2084 Internal Error: 
> AV00000000-R00000000-0
> Failed
> Elapsed time: 00:00:00.2
> 
> I have posted the project (a simple console application) to the 
> attachments group.
> 
> Can anybody compile this code in their Delphi XE IDE?

I can repeat the error also with XE and will later check if this is a
known issue or if it needs to be reported.
-- 
Uwe Schuster
http://www.bitcommander.de/blog
0
Uwe
9/16/2010 2:37:38 PM
Andrew Fionik wrote:

> I'm trying to compile the following code but the compiler gives me an
> internal error message. This is my second experiment with generics and
> it is complete failure. Do they work at all? I'm very disappointed.

It's not a generics bug.

> EventHandlerContainer.Add(EventHandlerContainer.Add(Listener1.EventHandler);
....
>EventHandlerContainer.Remove(Listener1.EventHandler);

The compiler does not know you are trying to pass a method by value.

You can use a helper function or temporary variable:
....

var
  EventHandlerContainer: TEventHandlerContainer<TObject, TSimpleEventArgs>;
  Listener1: TSimpleListener1;
  EventArgs: TSimpleEventArgs;
  Handler: TSimpleHandler;


function GetHandler(const Listener: TSimpleListener1): TSimpleHandler;
begin
  Result := Listener.EventHandler;
end;

begin
  try
    Listener1 := TSimpleListener1.Create;
    try
      Handler := Listener1.EventHandler;
      EventHandlerContainer := TSimpleEventHandlerContainer.Create;
      try
        EventHandlerContainer.Add(GetHandler(Listener1));
        try
          EventArgs := TSimpleEventArgs.Create('Hello');
          try
            EventHandlerContainer.Invoke(EventHandlerContainer, EventArgs);
          finally
            FreeAndNil(EventArgs);
          end;
        finally
          EventHandlerContainer.Remove(Handler);
        end;
      finally
        FreeAndNil(EventHandlerContainer);
      end;
    finally
      FreeAndNil(Listener1);
    end;
  except
    on E: Exception do
      WriteLn(E.ClassName, ': ', E.Message);
  end;

end.
1
Nenad
9/16/2010 11:47:07 PM
Andrew Fionik wrote:

> I'm trying to compile the following code but the compiler gives me an 
> internal error message. This is my second experiment with generics and 
> it is complete failure. Do they work at all? I'm very disappointed.
> 
> Checking project dependencies...
> Compiling Multicast.dproj (Debug configuration)
> [DCC Fatal Error] Multicast.dpr(152): F2084 Internal Error: 
> AV00000000-R00000000-0
> Failed
> Elapsed time: 00:00:00.2
> 
> I have posted the project (a simple console application) to the 
> attachments group.

I've simplified the issue to this test case. Please file a QC report.

{code}
program Multicast;

{$APPTYPE CONSOLE}

type
  TEventHandler<T> = procedure(const ASender: T) of object;

  TEventHandlerContainer<T> = class(TObject)
  public
    procedure Add(const AHandler: TEventHandler<T>);
  end;

  TSimpleHandler = TEventHandler<TObject>;

  TSimpleListener1 = class(TObject)
  public
    procedure EventHandler(const ASender: TObject);
  end;

procedure TEventHandlerContainer<T>.Add(const AHandler: TEventHandler<T>);
begin
end;

procedure TSimpleListener1.EventHandler(const ASender: TObject);
begin
end;

var
  EventHandlerContainer: TEventHandlerContainer<TObject>;
  Listener1: TSimpleListener1;
begin
  Listener1 := TSimpleListener1.Create;
  EventHandlerContainer := TEventHandlerContainer<TObject>.Create;
  EventHandlerContainer.Add(Listener1.EventHandler);
  WriteLn('PASS'); // on compile
end.
{code}
-- 
Uwe Schuster
http://www.bitcommander.de/blog
0
Uwe
9/16/2010 11:50:07 PM
Nenad Trkulja wrote:

> Andrew Fionik wrote:
> 
> > I'm trying to compile the following code but the compiler gives me an
> > internal error message. This is my second experiment with generics and
> > it is complete failure. Do they work at all? I'm very disappointed.
> 
> It's not a generics bug.
> 
> > EventHandlerContainer.Add(EventHandlerContainer.Add(Listener1.EventHandler);
> ...
> > EventHandlerContainer.Remove(Listener1.EventHandler);
> 
> The compiler does not know you are trying to pass a method by value.

It is a Generics bug. My test case works as expected without the type parameter.

{code}
program Multicast;

{$APPTYPE CONSOLE}

type
  TEventHandler = procedure(const ASender: TObject) of object;

  TEventHandlerContainer = class(TObject)
  public
    procedure Add(const AHandler: TEventHandler);
  end;

  TSimpleHandler = TEventHandler;

  TSimpleListener1 = class(TObject)
  public
    procedure EventHandler(const ASender: TObject);
  end;

procedure TEventHandlerContainer.Add(const AHandler: TEventHandler);
begin
  AHandler(nil);
end;

var
  Counter: Integer = 0;

procedure TSimpleListener1.EventHandler(const ASender: TObject);
begin
  Inc(Counter);
end;

var
  EventHandlerContainer: TEventHandlerContainer;
  Listener1: TSimpleListener1;
begin
  Listener1 := TSimpleListener1.Create;
  EventHandlerContainer := TEventHandlerContainer.Create;
  EventHandlerContainer.Add(Listener1.EventHandler);
  if Counter = 1 then
    WriteLn('PASS')
  else
    WriteLn('FAIL');
end.
{code}
-- 
Uwe Schuster
http://www.bitcommander.de/blog
0
Uwe
9/17/2010 12:12:10 AM
Uwe Schuster wrote:

> It is a Generics bug. My test case works as expected without the type parameter.

You are right. At least there is a workaround.
0
Nenad
9/17/2010 12:27:17 AM
On 17.09.2010 5:50, Uwe Schuster wrote:
> I've simplified the issue to this test case. Please file a QC report.

Yes. I will file a QC report. I have found an interesting effect. If we 
comment the following declaration:

TSimpleHandler = TEventHandler<TEventData>;

.... in the sample below it compiles and works.

But with that declaration, even completely unused, the compiler fails. 
It looks totally mystical for me.

Here is the sample.

program BugDemo2;
{$APPTYPE CONSOLE}
uses
	SysUtils;

type
	TEventHandler<T> = procedure(const ASender: T) of object;

	TEventHandlerContainer<T> = class(TObject)
	strict private
		FHandler:TEventHandler<T>;
	public
		procedure Add(const AHandler: TEventHandler<T>);
		procedure Invoke(const AValue:T);
	end;

	TEventData=class(TObject)
	strict private
		FValue:string;
	public
		constructor Create(const AValue:string);
		property Value:string read FValue;
	end;

	//TSimpleHandler = TEventHandler<TEventData>;

	TSimpleEventHandlerContainer=TEventHandlerContainer<TEventData>;

	TSimpleListener1 = class(TObject)
	public
		procedure EventHandler(const AData: TEventData);
	end;

procedure TEventHandlerContainer<T>.Add(const AHandler: TEventHandler<T>);
begin
	FHandler:=AHandler;
end;

procedure TSimpleListener1.EventHandler(const AData: TEventData);
begin
	WriteLn('I am alive!');
	WriteLn(AData.Value);
end;

procedure TEventHandlerContainer<T>.Invoke(const AValue:T);
begin
	FHandler(AValue);
end;

{ TEventData }

constructor TEventData.Create(const AValue: string);
begin
	inherited Create;
	FValue:=AValue;
end;

var
	EventHandlerContainer: TSimpleEventHandlerContainer;
	Listener1: TSimpleListener1;
	Data:TEventData;

begin
	Listener1 := TSimpleListener1.Create;
	try
		EventHandlerContainer := TSimpleEventHandlerContainer.Create;
		try
			EventHandlerContainer.Add(Listener1.EventHandler);
			Data:=TEventData.Create('Hello');
			try
				EventHandlerContainer.Invoke(Data);
			finally
				FreeAndNil(Data);
			end;
			WriteLn('Press Enter'); // on compile
		finally
			FreeAndNil(EventHandlerContainer);
     end;
	finally
		FreeAndNil(Listener1);
   end;
	ReadLn;
end.
0
Andrew
9/17/2010 5:42:43 AM
Andrew Fionik wrote:

> > I've simplified the issue to this test case. Please file a QC report.
> 
> Yes. I will file a QC report. 

TIA.

> I have found an interesting effect. If we 
> comment the following declaration:
> 
> TSimpleHandler = TEventHandler<TEventData>;
> 
> ... in the sample below it compiles and works.

I've noticed that too. I've used XE to simplify the test case, tried the simplified
version in 2010 and it compiled and thatswhy I've added this line from your code too.
-- 
Uwe Schuster
http://www.bitcommander.de/blog
0
Uwe
9/17/2010 10:25:27 AM
>> Yes. I will file a QC report.
On 17.09.2010 16:25, Uwe Schuster wrote:
> TIA.

QC 88158
0
Andrew
9/17/2010 1:13:00 PM
Andrew Fionik wrote:

> >> Yes. I will file a QC report.
> On 17.09.2010 16:25, Uwe Schuster wrote:
> > TIA.
> 
> QC 88158

Thanks.
-- 
Uwe Schuster
http://www.bitcommander.de/blog
0
Uwe
9/19/2010 12:45:59 PM
Reply:

Similar Artilces:

delphi XE2 + generics = F2084 Internal error: AV00000000-R00000000-0 :(
hello, in one unit i declare generics MyObj = class fMyGenericList: TMyGenericList<TMyListItem>: Property MyGenericList: TWinRE_TMyGenericList<TMyListItem> read fMyGenericList; end; in other unit i just do : MyObj.MyGenericList.Count; and i receive at compile time : F2084 Internal error: AV00000000-R00000000-0 :( any idea ? i m on XE2 update 4 ok, i found (it's a bug) it's seam that the problem was that getter and setter of some properties was defined in base class : TMyBASEGenericList<T> function Getxyz(...); pr...

Delpi XE2 compile error [DCC Fatal Error] F2084 Internal Error:
Hi, I am getting the following error when compiling a project ( 32 bit vcl ) It doesn't happen that often and it I can't remember a case when it was repeatable. I have recorded the following messages when a compile fails... [DCC Fatal Error] F2084 Internal Error: AV0A639D73-R0000000C-0 [DCC Fatal Error] F2084 Internal Error: AV09909D73-R0000000C-0 I usually just recompile and it works without errors. So I can't reproduce it. But this along with some other strange run time errors that are also not repeatable have me concerned. Unfortunately I haven't documented...

[DCC Fatal Error] AdvGDIP.pas(2825): F2084 Internal Error: AV221C241D-R2C647A6C-0
I m getting an internal error, as in the title of this note: [DCC Fatal Error] AdvGDIP.pas(2825): F2084 Internal Error: AV221C241D-R2C647A6C-0 This is highly reproducible, at least inside my rather large project. It happens in this way: 1. I add a line of code of the form: formref.gridonform.HideInplaceEdit; 2. I see Code Insight fail, probably on the name of the grid. 3. I attempt to build, and the error happens almost immediately, and the cursor is on the word implementation in the unit named. In another thread, Andrew Pailthorpe reported a similar fault in XE2. The unit reporte...

[DCC Fatal Error] Unit18.pas(94): F2084 Internal Error: AV09494487-R0000000C-0
Hi, I'm using DXE2 and I'm getting this F2084 Internal Error. I'm studying DXE2 RTTI and Generics. I'm very pleased with the results, but I got that Internal Error. Unit18 ends at line 92. After a lot of trial and error I found that the problem is in another unit. If I comment out a single line in that unit, the project compiles. Here is the code : (Fcxt is a TRTTIContext initialized upon class creation and freed on Destruction.) var typ : TRttiType; fld : TRttiField; PropAttr : TCustomAttribute; begin typ := Fctx.GetType...

[DCC Fatal Error] F2084 Internal Error: L2060
[DCC Fatal Error] F2084 Internal Error: L2060 I get this error a lot lately but i cannot find any information on it. What does it mean and what can i do to solve it. Sometimes even a rebuild of the project gives this error. I already found out that deleting (cleaning) all the projects dcu's is a solution, but i rather have a good error description to solve this permanent... Any information is appreciated.. Greetings, Marius Marius . wrote: > [DCC Fatal Error] F2084 Internal Error: L2060 > > I get this error a lot lately but i cannot find any information on...

[DCC Error] F2084 Internal Error: AV06EB4FCB-R0000080B-0
What is wrong with this????????????????? It did work for other privat values!!! Start thinking that C# or VB net has a more clever approach. At last they have a whole bunch of well designed and very performant coll's, etc. Also, MS provides FASTER & BETTER answers towards developers!!!! To my opinion, since the keydeveloper of Delphi ran to MS, Delphi is suffering a long and painfull dead. A bit like clipper in the old days, except, it took CA to give the final coup The same key developer has made VB and dot net a booming business. Specially by SOLVING outstanding issues ...

Delphi 2010 F2084 Internal Error TI894
Hi, I get following error when I enter following code in Delphi 2010 : CODE : -------- type TMyFunction = function(var FromFile : Text) : byte of object ; ERROR : ---------- [DCC Fatal Error] Unit1.pas(20): F2084 Internal Error: TI894 Thx in advance, Rob Dominiek Russe wrote: > I get following error when I enter following code in Delphi 2010 : > > CODE : > -------- > > type > TMyFunction = function(var FromFile : Text) : byte of object ; > > ERROR : > ---------- > > [DCC Fatal Error] Unit1.pas(20): F2084 Inter...

threadvar + generic class = [DCC Fatal Error] F2084 Internal Error: G5993
Ok got another bug in Generics for you causing F2084 Internal Error: G5993 Simple test case (place in New forms project): type TestClass<T> = class class threadvar I : Integer; end; Test = TestClass<TForm>; Have submitted to QC = 85960 Tim -- Dr Tim Kelly Technical Director Tirius Business Systems Ltd. ...

[DCC Fatal Error] name.pas(36): F2084 Internal Error: AV07BF4237-W00000003
I'm using Delphi XE2 update 4 and recently I've started having an odd problem on my one development machine, I'll open a project and work on it for a while then save all and then build see some errors and do more work. I'm able to do that some unspecified number of times and then when I build the project I get this (or a similar error) error "[DCC Fatal Error] name.pas(36): F2084 Internal Error: AV07BF4237-W00000003-1" and I have to exit the IDE and start it again. The size of the project doesn't seem to have any impact, for example the project I'm working ...

[DCC Fatal Error] uName.pas(68): F2084 Internal Error: AV07233E0B-W46AB6762
Hi All I have Embarcadero® Delphi® XE2 Version 16.0.4358.45540 And I'm sporadically experiencing the following error message:- [DCC Fatal Error] uUnitName.pas(68): F2084 Internal Error: AV07233E0B-W46AB6762-1 The compiler just highlights(in red) the reserved word "implementation" of the unit. I have to restart Delphi for the project to compile. Any ideas why? tia Andrew Pailthorpe wrote: > I have Embarcadero® Delphi® XE2 Version 16.0.4358.45540 > > And I'm sporadically experiencing the following error message:-...

[DCC Fatal Error] <Insert Unit here>(398): F2084 Internal Error: AV0808428F
Hi - Anyone else come across this type of error or can guide me as to where to look for the fault ? I removed the unit name from the error message as I doubt it is relevant. does the "AV.." mean that its an Access Violation error ? If I dont re-start the IDE and load a completely seperate project, I get the same message (only this time the unit name is changed.) If I re-start the IDE it fixes the problem. An insight would be much appreciated. Thanks. > {quote:title=Paul Slade wrote:}{quote} > Anyone else come across this type of error or can guide me as to whe...

Delphi XE: [DCC Fataler Fehler] F2084 Interner Fehler: AV221F6F4A-R00000014-0
Hi folks, I'm using in a new project the new RTTI in combination with Generics. In a DUnit test case I would like to use an Object guard which helps me to avoid the try finally block. <code> var pJSON: IObjGuard<TSerializerJSON>; pPerson: IObjGuard<TPerson>; pStream: IObjGuard<TMemoryStream>; begin pJSON := TObjGuard<TSerializerJSON>.Create; pPerson := TObjGuard<TPerson>.Create; pStream := TObjGuard<TMemoryStream>.Create; ... </code> After defining the variable pStream it is over, the compiler always...

Generating Datamodule
Delphi 2007 I'm trying to automatically generate the source for a data module from using an existing Paradox database defintiion, the database is reasonably large (100+ tables, 1000+fields) and is still evolving so I want to be able to generate a module now, and another one in a few weeks when it's changed. [I'm building a Blackfish equivalent, so it will be a DBExpress / Blackfish solution, so Paradox is irrelevant, just being used as source for database defintion] I've been able to generate a PAS and DFM file that will compile, but when I try to link I get the follow...

Web resources about - Delphi 2010: [DCC Fatal Error] F2084 Internal Error: AV00000000-R00000000-0 - embarcadero.delphi.general


Resources last updated: 1/13/2016 5:14:41 AM