From 69bab478d5d612f31860c1690fb6c6f899b35b2a Mon Sep 17 00:00:00 2001 From: emilylange Date: Sun, 16 Feb 2025 06:49:32 +0100 Subject: [PATCH] electron_34-bin: fix read out of range on aarch64 16k pages systems Previously in chromium (source build): 608b73b8be01613fcf4fb817204c7be1caef77b2 This works around a regression in chromium M131-134 that causes electron v33 and v34 on aarch64-linux with 16k pagesize (e.g. Asahi Linux) to crash. This commit applies this workaround only to electron v34, as v33.4.1, for which we have a soon to be merged PR open, already carries the workaround upstream. --- .../tools/electron/binary/generic.nix | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkgs/development/tools/electron/binary/generic.nix b/pkgs/development/tools/electron/binary/generic.nix index d63bd6a7b1e52..6864efed65798 100644 --- a/pkgs/development/tools/electron/binary/generic.nix +++ b/pkgs/development/tools/electron/binary/generic.nix @@ -131,6 +131,13 @@ let ] ); + # Fix read out of range on aarch64 16k pages builds + # https://github.com/NixOS/nixpkgs/pull/365364 + # https://github.com/NixOS/nixpkgs/pull/380991 + # Can likely be removed when v34.2.1 (or v32.3.0?) releases: + # https://github.com/electron/electron/pull/45571 + needsAarch64PageSizeFix = lib.versionAtLeast version "34" && stdenv.hostPlatform.isAarch64; + linux = finalAttrs: { buildInputs = [ glib @@ -153,6 +160,19 @@ let chmod u-x $out/libexec/electron/*.so* ''; + # We use null here to not cause unnecessary rebuilds. + dontWrapGApps = if needsAarch64PageSizeFix then true else null; + preFixup = + if needsAarch64PageSizeFix then + '' + wrapProgram "$out/libexec/electron/chrome_crashpad_handler" "''${gappsWrapperArgs[@]}" + wrapProgram "$out/libexec/electron/chrome-sandbox" "''${gappsWrapperArgs[@]}" + wrapProgram "$out/libexec/electron/electron" "''${gappsWrapperArgs[@]}" \ + --add-flags "--js-flags=--no-decommit-pooled-pages" + '' + else + null; + postFixup = '' patchelf \ --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \