lua-users home
lua-l archive

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


Hi all,

I don't know if my email was dispatched or not. I send you again the
original message

---------------
I've got a dirty problem using weak tables, I hope someone can help
me. What I'm doing is to keep a table that map windows objects to plot
objects using the windows as weak keys. In some cases I'm doing a
reverse lookup on this table to find out which window is referencing a
particular plot.

What troubles me is that in same cases the table still contain among
the key some windows that are already finalized. I was thinking that,
because the keys are weaks, they are eliminated from the table when
the GC finalizes the object. The problem is that it does not seem to
work that way and sometimes I can access an object already finalized.
------------------

I've made some progress to understand my problem: what Lua does is
- in a first (full) GC cycle Lua finalizes the objects but does not remove
  the weak keys from the table where they appears
- in a second full GC cycle Lua actually removes the keys from the tables
  as it should

It seems to me that this is really a bug because the keys from the weak
table should be eliminated in the same GC cycle when the object are finalized.

Please help me with this problem, unfortunately I'm not a Lua GC Guru :-)

I hope not to be annoying but I really need some helps...

Regards
Francesco

Thank in advance for the help.

Best regards,
Francesco