Skip to content

Commit 162d0ec

Browse files
Kalvin Leechromeos-ci-prod
authored andcommitted
PA: Remove no-op free() feature scaffolding
This CL is intended to be a no-op, as this feature was already launched in efdfb40bf1e9fba88f9001bf8c7da65c3ed3d60d. This CL * removes the `base::Feature` controlling no-op `free()`, * strips all `MakeFreeNoOp()` calls save (the launched) one, * moves the TODO onto the DPD feature, and * moves `MakeFreeNoOp()` into `partition_alloc_support`. Fixed: 40802063 Change-Id: I1d5e4f1c31287a3eb109961f92d348377f2fa75e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5937487 Reviewed-by: Keishi Hattori <[email protected]> Reviewed-by: Gabriel Charette <[email protected]> Commit-Queue: Kalvin Lee <[email protected]> Cr-Commit-Position: refs/heads/main@{#1373881} CrOS-Libchrome-Original-Commit: 8529bddee489dc7c0d2cb1a57f9653a453382050
1 parent 0ad9d04 commit 162d0ec

File tree

4 files changed

+28
-72
lines changed

4 files changed

+28
-72
lines changed

base/allocator/partition_alloc_features.cc

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ const base::FeatureParam<UnretainedDanglingPtrMode>
5656
&kUnretainedDanglingPtrModeOption,
5757
};
5858

59+
// Note: DPD conflicts with no-op `free()` (see
60+
// `base::allocator::MakeFreeNoOp()`). No-op `free()` stands down in the
61+
// presence of DPD, but hypothetically fully launching DPD should prompt
62+
// a rethink of no-op `free()`.
5963
BASE_FEATURE(kPartitionAllocDanglingPtr,
6064
"PartitionAllocDanglingPtr",
6165
#if PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_FEATURE_FLAG)
@@ -434,60 +438,6 @@ BASE_FEATURE(kUsePoolOffsetFreelists,
434438
base::FEATURE_DISABLED_BY_DEFAULT);
435439
#endif
436440

437-
BASE_FEATURE(kPartitionAllocMakeFreeNoOpOnShutdown,
438-
"PartitionAllocMakeFreeNoOpOnShutdown",
439-
#if PA_BUILDFLAG(IS_CHROMEOS)
440-
FEATURE_ENABLED_BY_DEFAULT
441-
#else
442-
FEATURE_DISABLED_BY_DEFAULT
443-
#endif
444-
);
445-
446-
constexpr FeatureParam<WhenFreeBecomesNoOp>::Option
447-
kPartitionAllocMakeFreeNoOpOnShutdownOptions[] = {
448-
{WhenFreeBecomesNoOp::kBeforePreShutdown, "before-preshutdown"},
449-
{WhenFreeBecomesNoOp::kBeforeHaltingStartupTracingController,
450-
"before-halting-startup-tracing-controller"},
451-
{
452-
WhenFreeBecomesNoOp::kBeforeShutDownThreads,
453-
"before-shutdown-threads",
454-
},
455-
{
456-
WhenFreeBecomesNoOp::kInShutDownThreads,
457-
"in-shutdown-threads",
458-
},
459-
{
460-
WhenFreeBecomesNoOp::kAfterShutDownThreads,
461-
"after-shutdown-threads",
462-
},
463-
};
464-
465-
const base::FeatureParam<WhenFreeBecomesNoOp>
466-
kPartitionAllocMakeFreeNoOpOnShutdownParam{
467-
&kPartitionAllocMakeFreeNoOpOnShutdown, "callsite",
468-
WhenFreeBecomesNoOp::kBeforePreShutdown,
469-
&kPartitionAllocMakeFreeNoOpOnShutdownOptions};
470-
471-
void MakeFreeNoOp(WhenFreeBecomesNoOp callsite) {
472-
CHECK(base::FeatureList::GetInstance());
473-
// Ignoring `free()` during Shutdown would allow developers to introduce new
474-
// dangling pointers. So we want to avoid ignoring free when it is enabled.
475-
// Note: For now, the DanglingPointerDetector is only enabled on 5 bots, and
476-
// on linux non-official configuration.
477-
// TODO(b/40802063): Reconsider this decision after the experiment.
478-
#if PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
479-
if (base::FeatureList::IsEnabled(features::kPartitionAllocDanglingPtr)) {
480-
return;
481-
}
482-
#endif // PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
483-
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
484-
if (base::FeatureList::IsEnabled(kPartitionAllocMakeFreeNoOpOnShutdown) &&
485-
kPartitionAllocMakeFreeNoOpOnShutdownParam.Get() == callsite) {
486-
allocator_shim::InsertNoOpOnFreeAllocatorShimOnShutDown();
487-
}
488-
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
489-
}
490-
491441
BASE_FEATURE(kPartitionAllocAdjustSizeWhenInForeground,
492442
"PartitionAllocAdjustSizeWhenInForeground",
493443
#if BUILDFLAG(IS_MAC)

base/allocator/partition_alloc_features.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,24 +133,6 @@ enum class BucketDistributionMode : uint8_t {
133133
kDenser,
134134
};
135135

136-
// Parameter for 'kPartitionAllocMakeFreeNoOpOnShutdown' feature which
137-
// controls when free() becomes a no-op during Shutdown()
138-
enum class WhenFreeBecomesNoOp {
139-
kBeforePreShutdown,
140-
kBeforeHaltingStartupTracingController,
141-
kBeforeShutDownThreads,
142-
kInShutDownThreads,
143-
kAfterShutDownThreads,
144-
};
145-
146-
// Inserts a no-op on 'free()' allocator shim at the front of the
147-
// dispatch chain if called from the appropriate callsite.
148-
BASE_EXPORT void MakeFreeNoOp(WhenFreeBecomesNoOp callsite);
149-
150-
BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocMakeFreeNoOpOnShutdown);
151-
extern const BASE_EXPORT base::FeatureParam<WhenFreeBecomesNoOp>
152-
kPartitionAllocMakeFreeNoOpOnShutdownParam;
153-
154136
BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocBackupRefPtr);
155137
extern const BASE_EXPORT base::FeatureParam<BackupRefPtrEnabledProcesses>
156138
kBackupRefPtrEnabledProcessesParam;

base/allocator/partition_alloc_support.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include "partition_alloc/pointers/raw_ptr.h"
5959
#include "partition_alloc/shim/allocator_shim.h"
6060
#include "partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.h"
61+
#include "partition_alloc/shim/allocator_shim_dispatch_to_noop_on_free.h"
6162
#include "partition_alloc/stack/stack.h"
6263
#include "partition_alloc/thread_cache.h"
6364

@@ -782,6 +783,22 @@ void ReconfigurePartitionForKnownProcess(const std::string& process_type) {
782783
// experiments.
783784
}
784785

786+
void MakeFreeNoOp() {
787+
// Ignoring `free()` during Shutdown would allow developers to introduce new
788+
// dangling pointers. So we want to avoid ignoring free when it is enabled.
789+
// Note: For now, the DanglingPointerDetector is only enabled on 5 bots, and
790+
// on linux non-official configuration.
791+
#if PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
792+
CHECK(base::FeatureList::GetInstance());
793+
if (base::FeatureList::IsEnabled(features::kPartitionAllocDanglingPtr)) {
794+
return;
795+
}
796+
#endif // PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
797+
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
798+
allocator_shim::InsertNoOpOnFreeAllocatorShimOnShutDown();
799+
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
800+
}
801+
785802
PartitionAllocSupport* PartitionAllocSupport::Get() {
786803
static auto* singleton = new PartitionAllocSupport();
787804
return singleton;

base/allocator/partition_alloc_support.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ BASE_EXPORT std::map<std::string, std::string> ProposeSyntheticFinchTrials();
3737
BASE_EXPORT void InstallDanglingRawPtrChecks();
3838
BASE_EXPORT void InstallUnretainedDanglingRawPtrChecks();
3939

40+
// Once called, makes `free()` do nothing. This is done to reduce
41+
// shutdown hangs on CrOS.
42+
// Does nothing if Dangling Pointer Detector (`docs/dangling_ptr.md`)
43+
// is not active.
44+
// Does nothing if allocator shim support is not built.
45+
BASE_EXPORT void MakeFreeNoOp();
46+
4047
// Allows to re-configure PartitionAlloc at run-time.
4148
class BASE_EXPORT PartitionAllocSupport {
4249
public:

0 commit comments

Comments
 (0)