From 06ecc51368bb4181c313dd6fea1bc573b9b9a033 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 6 Nov 2022 22:03:18 -0800 Subject: [PATCH 1/3] boehmgc: disable SOFT_VDB on powerpc64le for version 8.2.2 Upstream has not yet fixed the bug: https://github.com/ivmai/bdwgc/issues/376 https://github.com/ivmai/bdwgc/issues/479 However there is a recommended workaround: https://github.com/ivmai/bdwgc/issues/479#issuecomment-1279687537 This adds `CFLAGS_EXTRA=-DNO_SOFT_VDB` to the `makeFlags`, which prevents direct accesses to `/proc` being used for tracking dirtied pages (which must be rescanned): https://github.com/ivmai/bdwgc/blob/54522af853de28f45195044dadfd795c4e5942aa/include/private/gcconfig.h#L741 The collector will fall back to using mprotect() to trigger page faults on writes to clean pages and maintain its own dirty bits, which is slightly less efficient but (in this case) more reliable. Unreliable page-dirtiness bits can lead to use-after-free() corruption; this is not a situation where disabling the tests is a good idea. --- pkgs/development/libraries/boehm-gc/default.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkgs/development/libraries/boehm-gc/default.nix b/pkgs/development/libraries/boehm-gc/default.nix index 513ae50298e2..1a5924fbf55e 100644 --- a/pkgs/development/libraries/boehm-gc/default.nix +++ b/pkgs/development/libraries/boehm-gc/default.nix @@ -30,6 +30,17 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optional enableMmap "--enable-mmap" ++ lib.optional enableLargeConfig "--enable-large-config"; + # this stanza can be dropped when a release fixes this issue: + # https://github.com/ivmai/bdwgc/issues/376 + makeFlags = lib.optionals (stdenv.hostPlatform.isPower64 && + lib.versionAtLeast finalAttrs.version "8.2.2") + [ + # do not use /proc primitives to track dirty bits; see: + # https://github.com/ivmai/bdwgc/issues/479#issuecomment-1279687537 + # https://github.com/ivmai/bdwgc/blob/54522af853de28f45195044dadfd795c4e5942aa/include/private/gcconfig.h#L741 + "CFLAGS_EXTRA=-DNO_SOFT_VDB" + ]; + # `gctest` fails under emulation on aarch64-darwin doCheck = !(stdenv.isDarwin && stdenv.isx86_64); From 8260aed123ea511cd10fb5a3385fe07cd12d349a Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 6 Nov 2022 22:28:31 -0800 Subject: [PATCH 2/3] rephrase to avoid mass-rebuild --- pkgs/development/libraries/boehm-gc/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/boehm-gc/default.nix b/pkgs/development/libraries/boehm-gc/default.nix index 1a5924fbf55e..0e7a936b4c2a 100644 --- a/pkgs/development/libraries/boehm-gc/default.nix +++ b/pkgs/development/libraries/boehm-gc/default.nix @@ -32,14 +32,14 @@ stdenv.mkDerivation (finalAttrs: { # this stanza can be dropped when a release fixes this issue: # https://github.com/ivmai/bdwgc/issues/376 - makeFlags = lib.optionals (stdenv.hostPlatform.isPower64 && - lib.versionAtLeast finalAttrs.version "8.2.2") - [ + makeFlags = if (stdenv.hostPlatform.isPower64 && + lib.versionAtLeast finalAttrs.version "8.2.2") + then [ # do not use /proc primitives to track dirty bits; see: # https://github.com/ivmai/bdwgc/issues/479#issuecomment-1279687537 # https://github.com/ivmai/bdwgc/blob/54522af853de28f45195044dadfd795c4e5942aa/include/private/gcconfig.h#L741 "CFLAGS_EXTRA=-DNO_SOFT_VDB" - ]; + ] else null; # `gctest` fails under emulation on aarch64-darwin doCheck = !(stdenv.isDarwin && stdenv.isx86_64); From 7343a3b642cbdbac47770fe24d65aa9f9d23e6fa Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 6 Nov 2022 23:08:33 -0800 Subject: [PATCH 3/3] boehmgc: switch from versionAtLeast to == for powerpc workaround --- pkgs/development/libraries/boehm-gc/default.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/boehm-gc/default.nix b/pkgs/development/libraries/boehm-gc/default.nix index 0e7a936b4c2a..34e26f547093 100644 --- a/pkgs/development/libraries/boehm-gc/default.nix +++ b/pkgs/development/libraries/boehm-gc/default.nix @@ -30,10 +30,14 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optional enableMmap "--enable-mmap" ++ lib.optional enableLargeConfig "--enable-large-config"; - # this stanza can be dropped when a release fixes this issue: - # https://github.com/ivmai/bdwgc/issues/376 + # This stanza can be dropped when a release fixes this issue: + # https://github.com/ivmai/bdwgc/issues/376 + # The version is checked with == instead of versionAtLeast so we + # don't forget to disable the fix (and if the next release does + # not fix the problem the test failure will be a reminder to + # extend the set of versions requiring the workaround). makeFlags = if (stdenv.hostPlatform.isPower64 && - lib.versionAtLeast finalAttrs.version "8.2.2") + finalAttrs.version == "8.2.2") then [ # do not use /proc primitives to track dirty bits; see: # https://github.com/ivmai/bdwgc/issues/479#issuecomment-1279687537