mpl icon indicating copy to clipboard operation
mpl copied to clipboard

Unsafe scope checking for CCs

Open shwestrick opened this issue 4 years ago • 0 comments

Background: To do concurrent collection, we need an efficient way of checking whether or not a chunk is in scope of the collection. Currently this is done by, at the beginning of collection, marking each in-scope chunk with a identifier that uniquely identifies the collection. Then we can determine if a chunk is in-scope by inspecting the identifier. When CC was implemented, this was perfectly safe, because chunk descriptors (where the identifier is stored) were never overwritten throughout execution.

Problem: Under the new chunk allocator design (#135), this approach is no longer safe. Chunks freed by local collections might be recycled into a different size class, causing their chunk descriptor to be potentially overwritten. The likelihood of this causing a problem in practice, however, is exceedingly rare.

Suggested solution: At the beginning of CC, construct a hash-set of in-scope chunk ids. To check that an object is in-scope, get its chunk id (by masking its address) and check if the chunk-id is in the hash-set.

shwestrick avatar Apr 13 '21 15:04 shwestrick