Skip to content

Commit 0d1ce94

Browse files
v-gogtecopybara-github
authored andcommitted
Don't release pages if TCMalloc's page size is smaller than system page size.
PiperOrigin-RevId: 770786191 Change-Id: I047a4e79095cbd3641a6978aab8a8108db5b8a4a
1 parent f97f100 commit 0d1ce94

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tcmalloc/system-alloc.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,13 @@ uintptr_t SystemAllocator<Topology>::RandomMmapHint(size_t size,
753753
template <typename Topology>
754754
inline bool SystemAllocator<Topology>::ReleasePages(void* start,
755755
size_t length) const {
756+
// TODO(b/424551232): madvise rounds up length to the multiple of page size.
757+
// If TCMalloc's page size is lower than the system's page size, madvise may
758+
// corrupt the in-use memory. Return false to avoid this for now. We might
759+
// want to fix this by releasing only if all the TCMalloc pages within the
760+
// system page are free.
761+
if (kPageSize < GetPageSize()) return false;
762+
756763
int ret;
757764
// Note -- ignoring most return codes, because if this fails it
758765
// doesn't matter...

0 commit comments

Comments
 (0)