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

@@ -96,18 +96,19 @@ typedef struct arena_params_s {
// file. // file.
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_zero; // Fill allocated memory with 0x0? bool opt_randomize_small; // Randomization of small allocations?
size_t narenas; // Number of arenas. bool opt_zero; // Fill allocated memory with 0x0?
size_t quantum; // Allocation quantum. size_t narenas; // Number of arenas.
size_t quantum_max; // Max quantum-spaced allocation size. size_t quantum; // Allocation quantum.
size_t quantum_wide; // Allocation quantum (QuantuWide). size_t quantum_max; // Max quantum-spaced allocation size.
size_t quantum_wide_max; // Max quantum-wide-spaced allocation size. size_t quantum_wide; // Allocation quantum (QuantuWide).
size_t subpage_max; // Max subpage allocation size. size_t quantum_wide_max; // Max quantum-wide-spaced allocation size.
size_t large_max; // Max sub-chunksize allocation size. size_t subpage_max; // Max subpage allocation size.
size_t chunksize; // Size of each virtual memory mapping. size_t large_max; // Max sub-chunksize allocation size.
size_t page_size; // Size of pages. size_t chunksize; // Size of each virtual memory mapping.
size_t dirty_max; // Max dirty pages per arena. size_t page_size; // Size of pages.
size_t dirty_max; // Max dirty pages per arena.
// Current memory usage statistics. // Current memory usage statistics.
size_t mapped; // Bytes mapped (not necessarily committed). size_t mapped; // Bytes mapped (not necessarily committed).