[Lazarus] Enqueuing a callback from a thread via other class - or am I overcomplicating this ?

Juha Manninen juha.manninen62 at gmail.com
Sun Jun 18 12:20:32 CEST 2017


On Sat, Jun 17, 2017 at 11:25 PM, el es via Lazarus
<lazarus at lists.lazarus-ide.org> wrote:
> But when, during the course of Queue()d callback,
> I FreeAndNil() the object that had the pointer to the callback procedure, I
> get SIGSEGV pointing at CheckSynchronize in Application. (address F0F0F0F0).

I don't know the details of this issue but address F0F0F0F0 means you
used compiler flag -gt (trash variables) and the variable is
uninitialized or already freed.
Yes, the flag -gt is good, helps find such errors.


> Hence the question is, how can I know it is safe to free the object,
> that has the callback subscribed to it?
> One of the ways would be, to have a flag in that object, that the
> callback proc will set, and so the thread will know it's now safe to
> Free(andNil)() it.

A flag in an uninitialized or freed object does not help.

Juha


More information about the Lazarus mailing list