Marius Vollmer wrote:
Han-Wen Nienhuys <[EMAIL PROTECTED]> writes:


I think the right fix is to change the weak hashtable marking
algorithm to properly cope with circular references like this.  I will
try this and then come back to you.

Interesting. How would you go about doing that?


The marking would would rougly look like this (some special cases are
not considered, like improper alists):

    mark OBJ:
      if mark of OBJ is set:
        return
      set mark of OBJ
      if OBJ is a weak vector
        put it on POSTPONED_OBJECTS
      else
        mark references of OBJ

    gc:
      POSTPONED_OBJECTS = '()
      mark all root references
      while POSTPONED_OBJECTS not empty
        OBJS = POSTPONED_OBJECTS
        POSTPONED_OBJECTS = '()
        mark_weak_vector all OBJS
sweep
    mark_weak_vector OBJ:
      for all elements ELT of OBJ:
        for all pairs P on list ELT:
          if P is marked, break
          ITEM = car of P
          if ITEM is a pair:
            if (OBJ has weak keys and car of ITEM is unmarked)
            or (OBJ has weak values and cdr of ITEM is unmarked)
              remove P from ELT

what happens if the weak (c[ad]r ITEM) is marked through a postponed weak vector that you haven't processed yet? Then P is removed erroneously, or am I missing something?


--
 Han-Wen Nienhuys - [EMAIL PROTECTED] - http://www.xs4all.nl/~hanwen


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

Reply via email to