Closed
Description
Parent: #850
SFTMap implementations cast &self
to &mut self
for modifying its underlying sft: Vec<&'a (dyn SFT + Sync + 'static)>
. This table is accessed by multiple threads, but it needs to be updated occasionally. It is problematic in two ways:
- Each element can be read and updated at the same time. This is a data race which has undefined behaviour.
- After one thread grows the space, other threads can access the SFT for the extended part while the space that grew the space is still updating the SFT entries. See:
Line 81 in f1a0bb7
One way to solve the first problem is changing the elements of the Vec
to AtomicPtr
. However, & dyn Trait
is 16 bytes in size.
The "double-checked locking" algorithm can be used for data structures that are lazily initialised. I think the use pattern of SFT matches lazy initialisation in certain ways, and may be applicable.
Metadata
Metadata
Assignees
Labels
No labels