diff --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h --- a/compiler-rt/lib/scudo/standalone/combined.h +++ b/compiler-rt/lib/scudo/standalone/combined.h @@ -279,15 +279,18 @@ uptr computeOddEvenMaskForPointerMaybe(Options Options, uptr Ptr, uptr ClassId) { + const uptr Tag = 1; // Always exclude Tag 0 is may be used for headers. if (!Options.get(OptionBit::UseOddEvenTags)) - return 0; + return Tag; // If a chunk's tag is odd, we want the tags of the surrounding blocks to be // even, and vice versa. Blocks are laid out Size bytes apart, and adding // Size to Ptr will flip the least significant set bit of Size in Ptr, so // that bit will have the pattern 010101... for consecutive blocks, which we // can use to determine which tag mask to use. - return 0x5555U << ((Ptr >> SizeClassMap::getSizeLSBByClassId(ClassId)) & 1); + return Tag | + (0x5555U << ((Ptr >> SizeClassMap::getSizeLSBByClassId(ClassId)) & + 1)); } NOINLINE void *allocate(uptr Size, Chunk::Origin Origin,