Dear Christophe,
As you guessed, the finalization of weak dictionaries themselves is
bogus. After the end of garbage collection, the system checks the
contents of weak dictionaries, and finalizes the items that have not
been reached yet. Those items are "revived" in memory once they are
sent on a finalization stream. The problem is that the contents of a
weak dictionary that is revived at that moment is not correct. A fix
would be to redo the check on all revived weak dictionaries.
However, there is a workaround in your case. It will work if you don't
need to access the weak dictionary again. The idea is to finalize the
weak dictionary's stream, provided it has not been closed before. Try
the following in the OPI:
declare
R={Finalize.guardian proc {$ _} {Show dict_is_gone} end}
local S in
C={NewCell {WeakDictionary.new S}}
{R S} % finalize S instead of WD
end
{System.gcDo} % WD and S are still accessible from C
C:=nil % make WD unreachable, and S too
{System.gcDo} % shows "dict_is_gone"
Cheers,
raph
Christophe Taton wrote:
Hi all,
I am experiencing what I believe is a bug, usually ending in a segfault
or a freeze. After many tests, I reduced the code to this:
functor
import
System
Finalize
define
R = {Finalize.guardian
proc {$ X}
{System.show X}
end}
{R {WeakDictionary.new _}}
{System.gcDo}
end
As far as I have looked at this, it seems the collection of the weak
dictionary itself is the source of the bug.
Any help will be much appreciated.
Thanks,
Christophe Taton
------------------------------------------------------------------------
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users