Matheus Tavares <matheus.bernardino@xxxxxx> writes: > To fix the race condition (and later segmentation fault), let's reorder > the aforementioned steps so that the lock is not released between 1. > and 3. In other words, we hold the base in core only for ourselves without adding it to the base cache, apply the delta to produce the result and then place the base in the cache, and the reason why this change fixes the breakage is because the base we have locally and not in cache will not be seen by other people and will not be freed without our consent? Which does make sense. But I was confused by the explanation "lock is not released". We do release the same lock when we call unpack_compressed_entry(), and reaquire it before the unpack_compressed_entry() returns. What the reordering achieves is to protect the base from getting evicted when the unlocking and relocing happens, no? Thanks.