forked from OSchip/llvm-project
tsan: fix latent bug in shadow computation
We use kShadowCnt (number of shadow cells per application granule) when computing shadow, but it's wrong. We need the ratio between shadow and app memory (how much shadow is larger than app memory), which is kShadowMultiplier. Currently both are equal to 4, so it works fine. Use the correct constant. Reviewed By: melver Differential Revision: https://reviews.llvm.org/D108033
This commit is contained in:
parent
027c5a6adc
commit
ef2ff556a2
|
@ -840,7 +840,7 @@ struct MemToShadowImpl {
|
|||
DCHECK(IsAppMemImpl::Apply<Mapping>(x));
|
||||
return (((x) & ~(Mapping::kShadowMsk | (kShadowCell - 1))) ^
|
||||
Mapping::kShadowXor) *
|
||||
kShadowCnt +
|
||||
kShadowMultiplier +
|
||||
Mapping::kShadowAdd;
|
||||
}
|
||||
};
|
||||
|
@ -873,7 +873,8 @@ struct ShadowToMemImpl {
|
|||
// a bijection, so we try to restore the address as belonging to
|
||||
// low/mid/high range consecutively and see if shadow->app->shadow mapping
|
||||
// gives us the same address.
|
||||
uptr p = ((sp - Mapping::kShadowAdd) / kShadowCnt) ^ Mapping::kShadowXor;
|
||||
uptr p =
|
||||
((sp - Mapping::kShadowAdd) / kShadowMultiplier) ^ Mapping::kShadowXor;
|
||||
if (p >= Mapping::kLoAppMemBeg && p < Mapping::kLoAppMemEnd &&
|
||||
MemToShadowImpl::Apply<Mapping>(p) == sp)
|
||||
return p;
|
||||
|
|
Loading…
Reference in New Issue