[Lazarus] Log4D weirdness

Marcos Douglas md at delfire.net
Sun Dec 28 22:51:25 CET 2014


On Sun, Dec 28, 2014 at 1:03 AM, Hans-Peter Diettrich
<DrDiettrich2 at gmx.de> wrote:
> Am 27.12.2014 um 22:49 schrieb Marco van de Voort:
>>
>> On Fri, Dec 19, 2014 at 06:49:07PM -0300, Mario R. Carro wrote:
>>>
>>> There's a LogLog variable that is destroyed in the finalization section
>>> (and fails). The problem is that the TLogODSAppender created in the ctor
>>> ends up destroyed inside the AddAppender call. This is the AddAppender
>>> code:
>>>
>>> procedure TLogLogger.AddAppender(const Appender: ILogAppender);
>
> [...]
>>
>> Yes, this is a known kind of buggy code. (buildin assumptions of Delphi
>> code that only "happens" to work on Delphi). Delphi /usually/ destroys
>> automatically created temps at the end of a function, while FPC can also do
>> it after a block. Best is to explicitely keep a local variable reference,
>> local variable references are kept to the end at the moment, as you already
>> found out.
>>>
>>> Who is at fault here? Log4D? The compiler? Me?
>>
>> Hard to say, there is some opinion involved there.
>>
>> Like many cases, Delphi does not specify this behaviour, and in general
>> for
>> Delphi not much is known what of the implementation is intended, or what
>> is
>> coincidence.  This is aggrevated by the fact that too much Delphi code
>> messing with interface refcounting seems to be created with trial and
>> error.
>
> Also strings had (have?) problems with refcounting of *const* parameters in
> Delphi. As a first try I remove the "const", in case of unexpected trouble.

Delphi and FPC have problems with refcounting -- but I'm referring
only interfaces.
Circular references is a big problem too.

This link could help:
http://blog.synopse.info/post/2012/06/18/Circular-reference-and-zeroing-weak-pointers

Regards,
Marcos Douglas




More information about the Lazarus mailing list