This is an archive of the discontinued LLVM Phabricator instance.

[scudo][standalone] Allow setting release to OS
ClosedPublic

Authored by cferris on Feb 11 2020, 2:58 PM.

Details

Summary

Add a method to set the release to OS value as the system runs,
and allow this to be set differently in the primary and the secondary.
Also, add a default value to use for primary and secondary. This
allows Android to have a default that is different for
primary/secondary.

Update mallopt to support setting the release to OS value.

Diff Detail

Event Timeline

cferris created this revision.Feb 11 2020, 2:58 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 11 2020, 2:58 PM
Herald added subscribers: llvm-commits, Restricted Project, jfb, cryptoad. · View Herald Transcript

I added a parameter to the primary and secondary, but I'm not sure when to set using the default. Right now, if the flag release_to_os_interval is set to -1, then it uses the default. I think that it would be better to have the default always override, but what do you think?

I think this works.
Once the comment raised is addressed, this can go in like this, and my next step would be to change the parameters to a Config class like it's done in other places and like pcc@ did for the new sizeclassmap.

compiler-rt/lib/scudo/standalone/primary64.h
98

With this block, I don't think we can ever set a negative interval (eg: never release) via the options string if the default is not negative.
A possible solution could be to have a specific "not-specified" value for the parameter default maybe that would entice a fallback to the default value (an enum/define of INT32_MAX maybe or something negative)?

cferris updated this revision to Diff 244666.Feb 14 2020, 7:43 AM

Created a min and max release to OS value for the allocators.

Running some tests, 1 comment.

compiler-rt/lib/scudo/standalone/wrappers_c.inc
165

Now that value & secondary_interval have the same values, does it make sense to merge them?

cryptoad added inline comments.Feb 14 2020, 9:12 AM
compiler-rt/lib/scudo/standalone/combined.h
631

error: conversion from ‘scudo::sptr’ {aka ‘long int’} to ‘scudo::s32’ {aka ‘int’} may change value [-Werror=conversion]
so static_cast to s32.

634

Same here

cferris updated this revision to Diff 244710.Feb 14 2020, 10:41 AM
cferris marked 2 inline comments as done.

Add static_casts where needed.

cferris updated this revision to Diff 244714.Feb 14 2020, 10:49 AM
cferris marked an inline comment as done.

Update the mallopt and remove the ability to set the
primary and secondary differently.

cferris added inline comments.Feb 14 2020, 10:50 AM
compiler-rt/lib/scudo/standalone/wrappers_c.inc
165

Good point, I've removed the ability to set the two differently since it's not needed now, and I'm not sure if it's something we'll want in the future.

cryptoad accepted this revision.Feb 14 2020, 11:22 AM
This revision is now accepted and ready to land.Feb 14 2020, 11:22 AM
This revision was automatically updated to reflect the committed changes.