[Lazarus] Log4D weirdness
Hans-Peter Diettrich
DrDiettrich2 at gmx.de
Sun Dec 28 04:03:07 CET 2014
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.
DoDi
More information about the Lazarus
mailing list