[lazarus] New Bug Entered

Mattias Gaertner nc-gaertnma at netcologne.de
Mon Jul 14 05:08:08 EDT 2003


On Sun, 13 Jul 2003 18:28:08 -0400
bugtracker at miraclec.com wrote:

> 
> Title: Datamodule generates AV on Lazarus exit
> 
> Entered by: Tom Lisjac
> 
> When a datamodule is renamed, OldCreateOrder is set and OnCreate and
> OnDestroy events exist, Lazarus will AV upon exit with 1.0.10. Here are
> the steps to reproduce:
> 
> Bring up Lazarus in a new project.
> Add a datamodule with File | New | Datamodule
> With Property editor:
>    Rename the datamodule to dmt
>    Set OldCreationOrder to True
>    Create empty OnCreate and OnDestroy event handlers
> Exiting Lazarus (saving or not) generates an AV
> 
> This problem appeared after upgrading to 1.0.10 in a datamodule that had
> been working fine with 1.0.7.

Now, there you found a difficult thing. I always wonder, when it will
appear. The IDE creates datamodule/forms descendents on the fly. That means,
it really creates new classes and procedures at runtime. These procedures
are empty and do nothing. The current trick is to copy an empty procedure. I
was always sure, that this will give us trouble, as soon as the caller
checks the stack or uses some special calling convention. Now you find an
example:

try
  AnEvent(Self);
except
end;

When the 'except' frees the exception frame, it runs into trouble (internal
error).
I have commented the try..except in the LCL, so this error is hidden.
One correct solution is to create better "empty procedures". This means an
empty procedure, with the right length of parameters. I'm not sure how to do
this for all kinds of calling conventions and processors.
Another solution is to simulate procedures. That means the procedures are
not really set. But this requires changing TReader/TWriter to handle fake
events and the RTTI will be incomplete. 
I prefer the first solution.

Maybe a fpc guru can give me a hint.


Mattias






More information about the Lazarus mailing list