This is an archive of the discontinued LLVM Phabricator instance.

[scudo][standalone] Workaround for full regions on Android
ClosedPublic

Authored by cryptoad on Feb 13 2020, 9:27 AM.

Details

Summary

Due to Unity, we had to reduce our region sizes, but in some rare
situations, some programs (mostly tests AFAICT) manage to fill up
a region for a given size class.

So this adds a workaround for that attempts to allocate the block
from the immediately larger size class, wasting some memory but
allowing the application to keep going.

Diff Detail

Event Timeline

cryptoad created this revision.Feb 13 2020, 9:27 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 13 2020, 9:27 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
pcc accepted this revision.Feb 13 2020, 9:44 AM

LGTM

Does it make sense to write a test for this?

This revision is now accepted and ready to land.Feb 13 2020, 9:44 AM
hctim added inline comments.Feb 13 2020, 9:47 AM
compiler-rt/lib/scudo/standalone/combined.h
275

Why not do this for all platforms?

cryptoad marked an inline comment as done.Feb 13 2020, 9:50 AM
cryptoad added inline comments.
compiler-rt/lib/scudo/standalone/combined.h
275

We had to reduce the region sizes on Android to 256MB, other platforms usually have 1GB or more, which makes them less likely to run out of space in the primary.
Since it only surfaced on Android, I figured I would spare the other platforms the additional code.

In D74567#1874708, @pcc wrote:

Does it make sense to write a test for this?

Yes I am working on one. The idea is to add another class to the DeathConfig, fill the 1024 one and make sure it keeps on going with the 2048 one.

hctim accepted this revision.Feb 13 2020, 10:28 AM
hctim marked an inline comment as done.

LGTM w/ one suggestion

compiler-rt/lib/scudo/standalone/combined.h
275

i'm not sure you're saving either runtime or code size here - i'd say just make the branch

if (UNLIKELY(!Block) && SCUDO_CAN_USE_PRIMARY64) {

Up to you though.

cryptoad updated this revision to Diff 244485.Feb 13 2020, 11:22 AM

Adding the test here rather than later.
This made me realize that since the SizeClassAllocator64 is used on 32-bit
(region size permitting), the SCUDO_CAN_USE_PRIMARY64 check can't be applied.

cryptoad updated this revision to Diff 244500.Feb 13 2020, 12:04 PM

The previous one didn't have the changes to the DeathConfig SCM.

pcc accepted this revision.Feb 13 2020, 12:46 PM

LGTM

This revision was automatically updated to reflect the committed changes.