-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[scudo] Allow the quarantine code to be compiled out #151064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -184,9 +184,10 @@ class Allocator { | |
| const s32 ReleaseToOsIntervalMs = getFlags()->release_to_os_interval_ms; | ||
| Primary.init(ReleaseToOsIntervalMs); | ||
| Secondary.init(&Stats, ReleaseToOsIntervalMs); | ||
| Quarantine.init( | ||
| static_cast<uptr>(getFlags()->quarantine_size_kb << 10), | ||
| static_cast<uptr>(getFlags()->thread_local_quarantine_size_kb << 10)); | ||
| if (!AllocatorConfig::getQuarantineDisabled()) | ||
| Quarantine.init( | ||
| static_cast<uptr>(getFlags()->quarantine_size_kb << 10), | ||
| static_cast<uptr>(getFlags()->thread_local_quarantine_size_kb << 10)); | ||
| } | ||
|
|
||
| void enableRingBuffer() NO_THREAD_SAFETY_ANALYSIS { | ||
|
|
@@ -276,16 +277,18 @@ class Allocator { | |
| // the last two items). | ||
| void commitBack(TSD<ThisT> *TSD) { | ||
| TSD->assertLocked(/*BypassCheck=*/true); | ||
| Quarantine.drain(&TSD->getQuarantineCache(), | ||
| QuarantineCallback(*this, TSD->getSizeClassAllocator())); | ||
| if (!AllocatorConfig::getQuarantineDisabled()) | ||
|
||
| Quarantine.drain(&TSD->getQuarantineCache(), | ||
| QuarantineCallback(*this, TSD->getSizeClassAllocator())); | ||
| TSD->getSizeClassAllocator().destroy(&Stats); | ||
| } | ||
|
|
||
| void drainCache(TSD<ThisT> *TSD) { | ||
| TSD->assertLocked(/*BypassCheck=*/true); | ||
| Quarantine.drainAndRecycle( | ||
| &TSD->getQuarantineCache(), | ||
| QuarantineCallback(*this, TSD->getSizeClassAllocator())); | ||
| if (!AllocatorConfig::getQuarantineDisabled()) | ||
| Quarantine.drainAndRecycle( | ||
| &TSD->getQuarantineCache(), | ||
| QuarantineCallback(*this, TSD->getSizeClassAllocator())); | ||
|
||
| TSD->getSizeClassAllocator().drain(); | ||
| } | ||
| void drainCaches() { TSDRegistry.drainCaches(this); } | ||
|
|
@@ -612,7 +615,8 @@ class Allocator { | |
| #endif | ||
| TSDRegistry.disable(); | ||
| Stats.disable(); | ||
| Quarantine.disable(); | ||
| if (!AllocatorConfig::getQuarantineDisabled()) | ||
| Quarantine.disable(); | ||
| Primary.disable(); | ||
| Secondary.disable(); | ||
| disableRingBuffer(); | ||
|
|
@@ -623,7 +627,8 @@ class Allocator { | |
| enableRingBuffer(); | ||
| Secondary.enable(); | ||
| Primary.enable(); | ||
| Quarantine.enable(); | ||
| if (!AllocatorConfig::getQuarantineDisabled()) | ||
| Quarantine.enable(); | ||
| Stats.enable(); | ||
| TSDRegistry.enable(); | ||
| #ifdef GWP_ASAN_HOOKS | ||
|
|
@@ -1252,7 +1257,8 @@ class Allocator { | |
| // If the quarantine is disabled, the actual size of a chunk is 0 or larger | ||
| // than the maximum allowed, we return a chunk directly to the backend. | ||
| // This purposefully underflows for Size == 0. | ||
| const bool BypassQuarantine = !Quarantine.getCacheSize() || | ||
| const bool BypassQuarantine = AllocatorConfig::getQuarantineDisabled() || | ||
| !Quarantine.getCacheSize() || | ||
| ((Size - 1) >= QuarantineMaxChunkSize) || | ||
| !Header->ClassId; | ||
| if (BypassQuarantine) | ||
|
|
@@ -1642,7 +1648,8 @@ class Allocator { | |
| uptr getStats(ScopedString *Str) { | ||
| Primary.getStats(Str); | ||
| Secondary.getStats(Str); | ||
| Quarantine.getStats(Str); | ||
| if (!AllocatorConfig::getQuarantineDisabled()) | ||
| Quarantine.getStats(Str); | ||
| TSDRegistry.getStats(Str); | ||
| return Str->length(); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hit: brackets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.