Sorry alpine, I again don't really understand what you suggest to do and why this should be neccessary or recommendable.
Why: because you can't be sure what you found is what you're looking for! The AV has only manifested itself
once.
Sorry alpine, I again don't really understand what you suggest to do and why this should be neccessary or recommendable.
What I'm suggesting: to hunt for a dangling Self and to prove you hypothesis. It is easier (at least - doable) than waiting for the side effect of memory corruption on some other instance to reappear as an AV.
Consider the example:
program Project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
{$IFDEF HASAMIGA}
athreads,
{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, unit1
{ you can add units after this };
type
TDummy = class
procedure EventHandler(Sender: TObject);
end;
{$R *.res}
procedure TDummy.EventHandler(Sender: TObject);
begin
if not Assigned(Self) then // <-- Try to validate the Self pointer
Exit;
{Self.}SomeProperty := 47; // Will corrupt something?!
end;
begin
RequireDerivedFormResource := True;
Application.Scaled := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.OnActivate := @TDummy(Nil).EventHandler; // Supplying an invalid Self
Application.Run;
end.
Here an invalid Self was passed for the handler (line 33) and when called, line 25 should trigger an AV. Because of the precondition on line 22 it won't.
You can figure out how to validate Self on line 22, e.g. keeping track of freed instances and search Self amongst them, and when the validation fails then to write log or something. You may even dump the stack trace there.
This seems to be sufficient sure for me.
You can never be sure that the error isn't somewhere else. You can only be sure that it's no longer at that particular place.