[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua assertion during garbage collection when using a weak table
- From: Andrew Gierth <andrew@...>
- Date: Thu, 28 Mar 2019 22:16:04 +0000
>>>>> "Roberto" == Roberto Ierusalimschy <roberto@inf.puc-rio.br> writes:
Roberto> I am afraid we were wrong. If the table is modified while in
Roberto> list 'weak' (but still before the atomic phase),
How could that happen?
In between the final propagate step (which switched the state to
GCatomic) and the start of the atomic step, can anything ever call any
of the propagation functions? As far as I can tell, during that interval
the only changes are marking and barriers, which can result in objects
being added to 'gray' or 'grayagain' but not to 'weak'.
Only when the atomic step is called and the first propagateall(g) is
done do we actually start putting objects onto the 'weak' list, and from
that point we go straight into atomic() without executing any user code,
so no addition to the table can happen.
Or to put it differently, why is it not sufficient to just move the
assertion from its current spot to here:
case GCSatomic: {
lu_mem work;
+ lua_assert(g->ephemeron == NULL && g->weak == NULL);
propagateall(g); /* make sure gray list is empty */
work = atomic(L); /* work is what was traversed by 'atomic' */
entersweep(L);
g->GCestimate = gettotalbytes(g); /* first estimate */;
return work;
}
--
Andrew.