[scudo][standalone] Fix malloc_iterate
authorKostya Kortchinsky <kostyak@google.com>
Tue, 20 Aug 2019 16:17:08 +0000 (16:17 +0000)
committerKostya Kortchinsky <kostyak@google.com>
Tue, 20 Aug 2019 16:17:08 +0000 (16:17 +0000)
commit3e5360f19465479605de3e9cd7212bf4008f3949
treea58ca05ca51f0f4befe167193512e723282e6256
parent696630eaf2830526fe90bf05a9235e3bbd692c44
[scudo][standalone] Fix malloc_iterate

Summary:
cferris's Bionic tests found an issue in Scudo's `malloc_iterate`.

We were inclusive of both boundaries, which resulted in a `Block` that
was located on said boundary to be possibly accounted for twice, or
just being accounted for while iterating on regions that are not ours
(usually the unmapped ones in between Primary regions).

The fix is to exclude the upper boundary in `iterateOverChunks`, and
add a regression test.

This additionally corrects a typo in a comment, and change the 64-bit
Primary iteration function to not assume that `BatchClassId` is 0.

Reviewers: cferris, morehouse, hctim, vitalybuka, eugenis

Reviewed By: hctim

Subscribers: delcypher, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D66231

llvm-svn: 369400
compiler-rt/lib/scudo/standalone/combined.h
compiler-rt/lib/scudo/standalone/primary64.h
compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp