From 2733345b6ad9feebafae48e85fa679df4318ea51 Mon Sep 17 00:00:00 2001 From: Caner Altinbasak Date: Thu, 4 Jun 2026 16:13:39 +0100 Subject: [PATCH] gin: cap V8 CodeRange to 64MB on low-memory systems OS-21534 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On ARM64 devices with ≤512MB physical RAM (e.g. BrightSign Pagani), V8's default 256MB CodeRange reservation exceeds CommitLimit. Cap CodeRange to kMinimumCodeRangeSize (64MB) when physical memory is at or below 512MB. This allows the kernel to satisfy the mmap without requiring overcommit policy changes. Also re-exports the ICU timezone patch to fix unrelated patch drift. --- patches/chromium/.patches | 1 + ...erange_to_64mb_on_low-memory_systems.patch | 43 +++++++++++++++++++ ...rect_time_zone_deficiencies_os-20888.patch | 6 +-- 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 patches/chromium/gin_cap_v8_coderange_to_64mb_on_low-memory_systems.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 8767f6d654562..30313d75ffa9c 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -193,3 +193,4 @@ os-17474-ozone_add_nexus_backend_for_ozone.patch add_mse_support_to_brightsign_video_player_os-19598.patch gpu_enable_validating_command_decoder_for_brightsign_builds.patch feat_brightsign_add_mouse_wheel_scroll_to_evdev.patch +gin_cap_v8_coderange_to_64mb_on_low-memory_systems.patch diff --git a/patches/chromium/gin_cap_v8_coderange_to_64mb_on_low-memory_systems.patch b/patches/chromium/gin_cap_v8_coderange_to_64mb_on_low-memory_systems.patch new file mode 100644 index 0000000000000..16b2164535d7f --- /dev/null +++ b/patches/chromium/gin_cap_v8_coderange_to_64mb_on_low-memory_systems.patch @@ -0,0 +1,43 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Caner Altinbasak +Date: Thu, 4 Jun 2026 15:54:18 +0100 +Subject: gin: cap V8 CodeRange to 64MB on low-memory systems + +On embedded systems with <=512MB of physical RAM visible to the kernel +(e.g. BrightSign Pagani where 484MB is reserved for Broadcom BMEM), +the default V8 CodeRange of 256MB exceeds the kernel's overcommit +heuristic (CommitLimit). Both the browser and renderer processes need +their own CodeRange, so 2x256MB is impossible on a system with only +~235MB CommitLimit. + +When ConfigureDefaults leaves code_range_size at 0 (because +RLIMIT_DATA is unlimited), V8 falls back to kMaximalCodeRangeSize +(256MB on ARM64). This causes the renderer's mmap to either fail with +OOM. + +Fix by explicitly setting code_range_size to 64MB (kMinimumCodeRangeSize) +when physical memory is <=512MB and ConfigureDefaults did not already +set a code_range_size. This allows both processes to reserve their +CodeRange within the kernel's overcommit budget (2x64MB = 128MB). + +diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc +index 24127c579e149345cc9b937b17dbfe630b0d3c35..406fc211731fd28e3047675e09c26e265e97cbb3 100644 +--- a/gin/isolate_holder.cc ++++ b/gin/isolate_holder.cc +@@ -198,6 +198,16 @@ IsolateHolder::getDefaultIsolateParams() { + params->constraints.ConfigureDefaults( + base::SysInfo::AmountOfPhysicalMemory().InBytesUnsigned(), + base::SysInfo::AmountOfVirtualMemory().InBytes()); ++ // On memory-constrained systems (<=512MB usable RAM), the default CodeRange ++ // of 256MB is too large to be allocated in both the browser and renderer ++ // processes. Cap it to 64MB (V8's minimum) so that both processes can ++ // successfully mmap their CodeRange without exceeding the kernel's ++ // overcommit heuristic (CommitLimit). ++ if (base::SysInfo::AmountOfPhysicalMemory().InBytesUnsigned() <= ++ 512u * 1024u * 1024u && ++ params->constraints.code_range_size_in_bytes() == 0) { ++ params->constraints.set_code_range_size_in_bytes(64u * 1024u * 1024u); ++ } + params->array_buffer_allocator = g_array_buffer_allocator; + params->allow_atomics_wait = true; + params->external_references = g_reference_table; diff --git a/patches/icu/putil_correct_time_zone_deficiencies_os-20888.patch b/patches/icu/putil_correct_time_zone_deficiencies_os-20888.patch index 6d7fd372daf3f..d231df4fc1646 100644 --- a/patches/icu/putil_correct_time_zone_deficiencies_os-20888.patch +++ b/patches/icu/putil_correct_time_zone_deficiencies_os-20888.patch @@ -12,10 +12,10 @@ Add non-daylight-saving EST and MST zones so that we can check against them in the unit test. diff --git a/source/common/putil.cpp b/source/common/putil.cpp -index 42e8be1170af1de2151a2434b5459923825bb6eb..0e1b29d390415b1aee8d1acff5e0c66b2e3b6db5 100644 +index ea15fdff0b0c67d09daf5a403f038be572cd1fbf..bb7c66832b2ffe46588572de143a5c549c5356b1 100644 --- a/source/common/putil.cpp +++ b/source/common/putil.cpp -@@ -806,16 +806,16 @@ static const struct OffsetZoneMapping OFFSET_ZONE_MAPPINGS[] = { +@@ -801,16 +801,16 @@ static const struct OffsetZoneMapping OFFSET_ZONE_MAPPINGS[] = { {-43200, 1, "ANAT", "ANAST", "Asia/Anadyr"}, {-39600, 1, "MAGT", "MAGST", "Asia/Magadan"}, {-37800, 2, "LHST", "LHST", "Australia/Lord_Howe"}, @@ -35,7 +35,7 @@ index 42e8be1170af1de2151a2434b5459923825bb6eb..0e1b29d390415b1aee8d1acff5e0c66b {-25200, 1, "HOVT", "HOVST", "Asia/Hovd"}, {-25200, 1, "KRAT", "KRAST", "Asia/Krasnoyarsk"}, {-21600, 1, "NOVT", "NOVST", "Asia/Novosibirsk"}, -@@ -850,15 +850,17 @@ static const struct OffsetZoneMapping OFFSET_ZONE_MAPPINGS[] = { +@@ -845,15 +845,17 @@ static const struct OffsetZoneMapping OFFSET_ZONE_MAPPINGS[] = { {14400, 2, "PYT", "PYST", "America/Asuncion"}, {18000, 1, "CST", "CDT", "America/Havana"}, {18000, 1, "EST", "EDT", "US/Eastern"}, /* Conflicts with America/Grand_Turk */