[PATCH] D66979: [InstrProf] Tighten a check for malformed data records in raw profiles
David Li via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 29 19:31:35 PDT 2019
davidxl added inline comments.
================
Comment at: llvm/include/llvm/ProfileData/InstrProfReader.h:271
- const uint64_t *getCounter(IntPtrT CounterPtr) const {
- ptrdiff_t Offset = (swap(CounterPtr) - CountersDelta) / sizeof(uint64_t);
+ ptrdiff_t getCounterOffset(IntPtrT CounterPtr) const {
+ return (swap(CounterPtr) - CountersDelta) / sizeof(uint64_t);
----------------
add a documentation " Returns the double word offset of a counter to the start of the counter segment'
================
Comment at: llvm/lib/ProfileData/InstrProfReader.cpp:419
- // Check bounds.
- if (RawCounts.data() < CountersStart ||
- RawCounts.data() + RawCounts.size() > NamesStartAsCounter)
+ // Check bounds. Note that the counter pointer embedded in the data record
+ // may itself be corrupt.
----------------
how does the corruption happen?
================
Comment at: llvm/lib/ProfileData/InstrProfReader.cpp:423
return error(instrprof_error::malformed);
+ ptrdiff_t CounterOffset = getCounterOffset(CounterPtr);
+ if (CounterOffset < 0 || CounterOffset > MaxNumCounters ||
----------------
should it assert to be zero?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66979/new/
https://reviews.llvm.org/D66979
More information about the llvm-commits
mailing list