Bug 1917844 - Assert correct jemalloc randomization state on Content and non Content processes r=jld,glandium

Differential Revision: https://phabricator.services.mozilla.com/D221971
This commit is contained in:
Alexandre Lissy
2024-10-16 20:10:55 +00:00
parent aebcff42c3
commit 7af8ad1bff
4 changed files with 28 additions and 12 deletions

View File

@@ -804,6 +804,13 @@ void ContentChild::Init(mozilla::ipc::UntypedEndpoint&& aEndpoint,
PendingInputEventHangAnnotator::sSingleton); PendingInputEventHangAnnotator::sSingleton);
})); }));
#endif #endif
#if defined(MOZ_MEMORY) && defined(DEBUG)
jemalloc_stats_t stats;
jemalloc_stats(&stats);
MOZ_ASSERT(!stats.opt_randomize_small,
"Content process should not randomize small allocations");
#endif
} }
void ContentChild::AddProfileToProcessName(const nsACString& aProfile) { void ContentChild::AddProfileToProcessName(const nsACString& aProfile) {

View File

@@ -138,6 +138,13 @@ bool UtilityProcessImpl::Init(int aArgc, char* aArgv[]) {
return false; return false;
} }
#if defined(MOZ_MEMORY) && defined(DEBUG)
jemalloc_stats_t stats;
jemalloc_stats(&stats);
MOZ_ASSERT(stats.opt_randomize_small,
"Utility process should randomize small allocations");
#endif
return mUtility->Init(TakeInitialEndpoint(), nsCString(*parentBuildID), return mUtility->Init(TakeInitialEndpoint(), nsCString(*parentBuildID),
*sandboxingKind); *sandboxingKind);
} }

View File

@@ -4878,6 +4878,7 @@ inline void MozJemalloc::jemalloc_stats_internal(
// Gather runtime settings. // Gather runtime settings.
aStats->opt_junk = opt_junk; aStats->opt_junk = opt_junk;
aStats->opt_randomize_small = opt_randomize_small;
aStats->opt_zero = opt_zero; aStats->opt_zero = opt_zero;
aStats->quantum = kQuantum; aStats->quantum = kQuantum;
aStats->quantum_max = kMaxQuantumClass; aStats->quantum_max = kMaxQuantumClass;

View File

@@ -97,6 +97,7 @@ typedef struct arena_params_s {
typedef struct { typedef struct {
// Run-time configuration settings. // Run-time configuration settings.
bool opt_junk; // Fill allocated memory with kAllocJunk? bool opt_junk; // Fill allocated memory with kAllocJunk?
bool opt_randomize_small; // Randomization of small allocations?
bool opt_zero; // Fill allocated memory with 0x0? bool opt_zero; // Fill allocated memory with 0x0?
size_t narenas; // Number of arenas. size_t narenas; // Number of arenas.
size_t quantum; // Allocation quantum. size_t quantum; // Allocation quantum.