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-17 06:29:54 +00:00
parent d37fc481d9
commit a0ab183c01
4 changed files with 30 additions and 12 deletions

View File

@ -804,6 +804,15 @@ void ContentChild::Init(mozilla::ipc::UntypedEndpoint&& aEndpoint,
PendingInputEventHangAnnotator::sSingleton);
}));
#endif
// Bug 1925181: Unrelated to forkserver, the android content processes are
// created in a way that makes them not follow this option correctly
#if defined(MOZ_MEMORY) && defined(DEBUG) && !defined(ANDROID)
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) {

View File

@ -138,6 +138,13 @@ bool UtilityProcessImpl::Init(int aArgc, char* aArgv[]) {
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),
*sandboxingKind);
}

View File

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

View File

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