bug-guile
[Top][All Lists]
Advanced

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

bug#12095: Protecting pointer on bytevector with guardian does not prote


From: Daniel Hartwig
Subject: bug#12095: Protecting pointer on bytevector with guardian does not protect memory
Date: Mon, 8 Oct 2012 22:10:54 +0800

On 8 October 2012 21:44, Ludovic Courtès <address@hidden> wrote:
>> On 8 October 2012 04:38, Ludovic Courtès <address@hidden> wrote:
>> Right.  But then the pointer is being collected even though it remains
>> inside the guardian, in the example it is never extracted from there.
>
> Well, when the object reaches the guardian’s zombie list, that’s because
> it’s been finalized, so any weak references from that object can also be
> nullified.

Ah.  So I thought that being in the zombie list prevented any
finalization, thus when the guardian returns an object it is still
fully functional and only after the reference is lost again does it
really get finalized.

I will have to reread the doc for make-guardian where it talks about
the weak links, perhaps with a healthy amount of source-code
inspection ;-)

Admittedly the test case here is quite contrived, and I agreed with
your next remark in the original (pre-bug-report) thread.

> Anyway, guardians are not a mechanism to protect objects from being
> GC’d.  To prevent the bytevector from being GC’d, you should either keep
> the pointer object or the bytevector itself in non-GC’d memory, such as
> a global variable or hash table.

Yes.  The intended use was obviously troubled, but it still seemed odd
about the guardian's lack of protection.

> How does it help?  Should we close the bug?  :-)

Sure.  At least you seem convinced and you has actually hacked on it :-)

Regards





reply via email to

[Prev in Thread] Current Thread [Next in Thread]