Re: GWeakNotify fired earlier than expected



On Mon, Mar 16, 2009 at 5:51 PM, Havoc Pennington
<havoc pennington gmail com> wrote:
Hi,

On Mon, Mar 16, 2009 at 12:45 PM, IdaRub <idarub gmail com> wrote:
After reading the gobject code a bit more, it seems that weak
references are fired on dispose, not finalize:


Right, that's correct.

All of the documentation I could find states that it happens during
finalization, but it seems it should all say that it happens during
dispose.

Probably true. dispose is typically done during finalize, but can
happen sooner also. dispose can happen multiple times.

In my example this detail is actually very important.
Doesn't look like there is a way to catch dispose without shimming the
instance handler.  Any ideas?

You mean there's no way to catch finalize?

Finalize deliberately can't be intercepted, because it raises a lot of
thorny issues about reentrancy; what if the object is used or its
refcount increased during finalization?

It would be nice if you could intercept it, the author being
responsible for understanding what finalize means, and not doing
anything inappropriate.  I was attempting to write some ownership
debugging code, basically something like leak and use-after-free
detection for a few specific object.  We'll catch this other ways
though, so I suppose I will drop this idea.

Thanks for your great reply.


So things are split into two phases, dispose() which you can get
notifications about (and which can happen multiple times); and
finalize which actually frees the object.

Havoc




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]