summaryrefslogtreecommitdiff
path: root/standalone/combined.h
diff options
context:
space:
mode:
Diffstat (limited to 'standalone/combined.h')
-rw-r--r--standalone/combined.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/standalone/combined.h b/standalone/combined.h
index bd78d79857e..e8390a7b44f 100644
--- a/standalone/combined.h
+++ b/standalone/combined.h
@@ -267,6 +267,17 @@ public:
bool UnlockRequired;
auto *TSD = TSDRegistry.getTSDAndLock(&UnlockRequired);
Block = TSD->Cache.allocate(ClassId);
+ // If the allocation failed, the most likely reason with a 64-bit primary
+ // is the region being full. In that event, retry once using the
+ // immediately larger class (except if the failing class was already the
+ // largest). This will waste some memory but will allow the application to
+ // not fail.
+ if (SCUDO_ANDROID) {
+ if (UNLIKELY(!Block)) {
+ if (ClassId < SizeClassMap::LargestClassId)
+ Block = TSD->Cache.allocate(++ClassId);
+ }
+ }
if (UnlockRequired)
TSD->unlock();
} else {