Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glibc: 2.33-108 -> 2.34-115 #133431

Merged
merged 73 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
97acaf6
glibc: 2.33-108 -> 2.34-115
Ma27 Aug 4, 2021
7459a40
stdenv-bootstrap: force using new libc from stage2
Ma27 Aug 22, 2021
7bc32b3
glibc: symlink `libpthread.so -> libpthread.so.0` (same for `-lrt`) f…
Ma27 Aug 22, 2021
49028fb
findutils: fix build w/glibc-2.34
Ma27 Aug 23, 2021
9fe34cc
glibc: also create backwards-compat symlinks for libdl and libutil
Ma27 Aug 24, 2021
f363b7c
boost1{69,70,72}: fix build w/glibc-2.34
Ma27 Aug 27, 2021
1b8aa88
glibc: revert `/bin/bash` usage
Ma27 Aug 27, 2021
2357e82
gdb: fix build w/glibc-2.34
Ma27 Sep 23, 2021
3aa6c49
libressl: fix build w/glibc-2.34
Ma27 Sep 8, 2021
8631ba1
fuse: fix build w/glibc-2.34
Ma27 Sep 16, 2021
486f248
catch: fix build w/glibc-2.34
Ma27 Sep 16, 2021
f81f59d
autofs: fix build w/glibc-2.34
Ma27 Sep 17, 2021
b9078e5
qt515.qtwebengine: fix build w/glibc-2.34
Ma27 Sep 18, 2021
0caf7e5
qt514.qtwebengine: fix build w/glibc-2.34
Ma27 Sep 18, 2021
96418eb
rcs: fix build w/glibc-2.34
Ma27 Sep 18, 2021
48d7135
emacs: fix build w/glibc-2.34
Ma27 Sep 21, 2021
1470227
postfix: fix build w/glibc-2.34
Ma27 Sep 30, 2021
917b7e5
ocaml: fix build w/glibc-2.34
Ma27 Sep 30, 2021
8e16dcc
openjdk11: fix build w/glibc-2.34
Ma27 Oct 3, 2021
f97b995
texinfo: fix build w/glibc-2.34
Ma27 Oct 3, 2021
bcf8aef
ocaml 4.10/4.11: fix build w/glibc-2.34
Ma27 Oct 8, 2021
f8a7d99
spdlog: 1.8.5 -> 1.9.2, fix build w/glibc-2.34
Ma27 Oct 9, 2021
49a7ee9
seasocks: fix build w/glibc-2.34
Ma27 Oct 9, 2021
c205067
leatherman: fix build w/glibc-2.34
Ma27 Oct 9, 2021
b770794
eternal-terminal: fix build w/glibc-2.34
Ma27 Oct 9, 2021
c905ab5
trenchbroom: fix build w/glibc-2.34
Ma27 Oct 10, 2021
7c57816
trafficserver: fix build w/glibc-2.34
Ma27 Oct 13, 2021
d4593d4
pdfslicer: fix build w/glibc-2.34
Ma27 Oct 13, 2021
a3f4ff5
openmw: mark as broken
Ma27 Oct 13, 2021
dbe99a0
ntp: fix build w/glibc-2.34
Ma27 Oct 13, 2021
f8fc20d
breakpad: fix build w/glibc-2.34
Ma27 Oct 13, 2021
65f5fdb
arangodb*: fix build w/glibc-2.34
Ma27 Oct 13, 2021
84635a6
apitrace: fix build w/glibc-2.34
Ma27 Oct 14, 2021
40fc009
aspcud: fix build w/glibc-2.34
Ma27 Oct 14, 2021
0bdcc48
conky: fix build w/glibc-2.34
Ma27 Oct 14, 2021
29e14f8
polyml*: fix build w/glibc-2.34
Ma27 Oct 17, 2021
da905d4
nixos/stage-1: fix `modprobe` in initial ramdisk on systems w/glibc-2.34
Ma27 Oct 28, 2021
5188650
libowfat: mark as broken
Ma27 Oct 31, 2021
5f56cd5
tiscamera: fix build w/glibc-2.34
Ma27 Oct 31, 2021
18d915e
ursadb: fix build w/glibc-2.34
Ma27 Oct 31, 2021
89caa8e
libfive: mark as broken
Ma27 Oct 31, 2021
fe58c18
libspf2: fix build w/glibc-2.34
Ma27 Oct 31, 2021
6b98a5e
nethack-qt: fix build w/glibc-2.34
Ma27 Oct 31, 2021
748faeb
glibc: don't hide symbol `__nss_files_fopen`
Ma27 Jan 3, 2022
1046c86
libosmscout: fix build w/glibc-2.34
Ma27 Jan 9, 2022
c0f4954
maude: fix build w/glibc-2.34
Ma27 Jan 9, 2022
4427e54
jetbrains.jdk: fix build w/glibc-2.34
Ma27 Jan 9, 2022
81e0c94
xnee: fix build w/glibc-2.34
Ma27 Jan 9, 2022
7605d49
qt512.qtwebengine: fix build w/glibc-2.34
Ma27 Jan 9, 2022
f319309
djmount: fix build w/glibc-2.34
Ma27 Jan 9, 2022
52bba1d
clingcon: fix build w/glibc-2.34
Ma27 Jan 10, 2022
322c490
mustache-hpp: fix build w/glibc-2.34
Ma27 Jan 10, 2022
a2ac7c6
recastnavigation: fix build w/glibc-2.34
Ma27 Jan 10, 2022
5f9c36c
spdlog_0: fix build w/glibc-2.34
Ma27 Jan 10, 2022
8ba95b6
symengine: fix build w/glibc-2.34
Ma27 Jan 10, 2022
6a97775
zeroc-ice: fix build w/glibc-2.34
Ma27 Jan 11, 2022
e10ea96
gcc{7,9,10}: apply patches for asan w/glibc-2.34
Ma27 Jan 11, 2022
64f9c92
soci: fix build w/glibc-2.34
Ma27 Jan 23, 2022
da55ba2
sfizz: fix build w/glibc-2.34, actually enable tests
Ma27 Jan 28, 2022
9a9fff5
quvi*: mark as broken
Ma27 Jan 28, 2022
357dd9e
zeroc-ice-36: remove, unmaintained
Ma27 Jan 28, 2022
2db6c7e
jumanpp: fix build w/glibc-2.34
Ma27 Jan 28, 2022
b43a356
cpp-hocon: fix build w/glibc-2.34
Ma27 Jan 28, 2022
6320b72
cataclysm-dda: fix build w/glibc-2.34
Ma27 Jan 28, 2022
25172c9
securefs: fix build w/glibc-2.34
Ma27 Jan 28, 2022
11597d1
sfxr-qt: fix build w/glibc-2.34
Ma27 Jan 28, 2022
e9187ab
gdb: remove `--disable-sim` fix
Ma27 Feb 27, 2022
69af73d
texinfo: review fixes
Ma27 Feb 27, 2022
e110983
glibc: add empty libpthread.a
Ma27 Feb 27, 2022
1077a6e
nixos/stage-1: typo fixes
Ma27 Feb 27, 2022
91fa765
stdenv: revert gcc hack
Ma27 Feb 27, 2022
41eb407
Revert "jetbrains.jdk: fix build w/glibc-2.34"
Ma27 Feb 27, 2022
82580b1
cataclysm-dda: fix eval
Ma27 Feb 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nixos/modules/system/boot/stage-1-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ done
mkdir -p /lib
ln -s @modulesClosure@/lib/modules /lib/modules
ln -s @modulesClosure@/lib/firmware /lib/firmware
echo @extraUtils@/bin/modprobe > /proc/sys/kernel/modprobe
# see comment in stage-1.nix for explanation
echo @extraUtils@/bin/modprobe-kernel > /proc/sys/kernel/modprobe
Ma27 marked this conversation as resolved.
Show resolved Hide resolved
for i in @kernelModules@; do
info "loading module $(basename $i)..."
modprobe $i
Expand Down
20 changes: 20 additions & 0 deletions nixos/modules/system/boot/stage-1.nix
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,26 @@ let
copy_bin_and_libs ${pkgs.kmod}/bin/kmod
ln -sf kmod $out/bin/modprobe

# Dirty hack to make sure the kernel properly loads modules
# such as ext4 on demand (e.g. on a `mount(2)` syscall). This is necessary
# because `kmod` isn't linked against `libpthread.so.0` anymore (since
# it was merged into `libc.so.6` since version `2.34`), but still needs
# to access it for some reason. This is not an issue in stage-1 itself
# because of the `LD_LIBRARY_PATH`-variable and anytime later because the rpath of
# kmod/modprobe points to glibc's `$out/lib` where `libpthread.so.6` exists.
# However, this is a problem when the kernel calls `modprobe` inside
# the initial ramdisk because it doesn't know about the
# `LD_LIBRARY_PATH` and the rpath was nuked.
#
# Also, we can't use `makeWrapper` here because `kmod` only does
# `modprobe` functionality if `argv[0] == "modprobe"`.
cat >$out/bin/modprobe-kernel <<EOF
#!$out/bin/ash
export LD_LIBRARY_PATH=$out/lib
exec $out/bin/modprobe "\$@"
EOF
chmod +x $out/bin/modprobe-kernel

# Copy resize2fs if any ext* filesystems are to be resized
${optionalString (any (fs: fs.autoResize && (lib.hasPrefix "ext" fs.fsType)) fileSystems) ''
# We need mke2fs in the initrd.
Expand Down
7 changes: 6 additions & 1 deletion pkgs/applications/audio/sfizz/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ lib, stdenv, fetchFromGitHub, libjack2, libsndfile, xorg, freetype
, libxkbcommon, cairo, glib, gnome, flac, libogg, libvorbis, libopus, cmake
, pango, pkg-config }:
, pango, pkg-config, catch2
}:

stdenv.mkDerivation rec {
pname = "sfizz";
Expand Down Expand Up @@ -40,6 +41,8 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ cmake pkg-config ];

postPatch = ''
cp ${catch2}/include/catch2/catch.hpp tests/catch2/catch.hpp

substituteInPlace plugins/editor/external/vstgui4/vstgui/lib/platform/linux/x11fileselector.cpp \
--replace 'zenitypath = "zenity"' 'zenitypath = "${gnome.zenity}/bin/zenity"'
substituteInPlace plugins/editor/src/editor/NativeHelpers.cpp \
Expand All @@ -48,6 +51,8 @@ stdenv.mkDerivation rec {

cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Release" "-DSFIZZ_TESTS=ON" ];

doCheck = true;

meta = with lib; {
homepage = "https://github.com/sfztools/sfizz";
description = "SFZ jack client and LV2 plugin";
Expand Down
7 changes: 7 additions & 0 deletions pkgs/applications/audio/sfxr-qt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
, qtquickcontrols2
, SDL
, python3
, catch2
}:

mkDerivation rec {
Expand All @@ -21,6 +22,10 @@ mkDerivation rec {
fetchSubmodules = true;
};

postPatch = ''
cp ${catch2}/include/catch2/catch.hpp 3rdparty/catch2/single_include/catch2/catch.hpp
'';

nativeBuildInputs = [
cmake
extra-cmake-modules
Expand All @@ -33,6 +38,8 @@ mkDerivation rec {
SDL
];

doCheck = true;

meta = with lib; {
homepage = "https://github.com/agateau/sfxr-qt";
description = "A sound effect generator, QtQuick port of sfxr";
Expand Down
5 changes: 5 additions & 0 deletions pkgs/applications/editors/emacs/27.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ import ./generic.nix (rec {
url = "https://git.savannah.gnu.org/cgit/emacs.git/patch/?id=a88f63500e475f842e5fbdd9abba4ce122cdb082";
sha256 = "sha256-RF9b5PojFUAjh2TDUW4+HaWveV30Spy1iAXhaWf1ZVg=";
})
# glibc 2.34 compat
(fetchpatch {
url = "https://src.fedoraproject.org/rpms/emacs/raw/181aafcdb7ee2fded9fce4cfc448f27edccc927f/f/emacs-glibc-2.34.patch";
sha256 = "sha256-2o3C/jhZPl2OW/LmVPt/fhdwbS9NOdF9lVEF1Kn9aEk=";
})
];
})
6 changes: 6 additions & 0 deletions pkgs/applications/graphics/apitrace/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ stdenv.mkDerivation rec {
owner = "apitrace";
};

patches = [
# glibc 2.34 compat
# derived from https://github.com/apitrace/apitrace/commit/d28a980802ad48568c87da02d630c8babfe163bb
./glibc-2.34-compat.patch
];

# LD_PRELOAD wrappers need to be statically linked to work against all kinds
# of games -- so it's fine to use e.g. bundled snappy.
buildInputs = [ libX11 procps python2 libdwarf qtbase qtwebkit ];
Expand Down
13 changes: 13 additions & 0 deletions pkgs/applications/graphics/apitrace/glibc-2.34-compat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/wrappers/dlsym.cpp b/wrappers/dlsym.cpp
index 2eda082..0c0c8ee 100644
--- a/wrappers/dlsym.cpp
+++ b/wrappers/dlsym.cpp
@@ -34,7 +34,7 @@
#include "os.hpp"


-#ifdef __GLIBC__
+#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 34


#include <dlfcn.h>
6 changes: 6 additions & 0 deletions pkgs/applications/misc/pdfslicer/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ stdenv.mkDerivation rec {
sha256 = "0sja0ddd9c8wjjpzk2ag8q1lxpj09adgmhd7wnsylincqnj2jyls";
};

postPatch = ''
# Don't build tests, vendored catch doesn't build with latest glibc.
substituteInPlace CMakeLists.txt \
--replace "add_subdirectory (tests)" ""
'';

nativeBuildInputs = [
cmake
gettext
Expand Down
13 changes: 13 additions & 0 deletions pkgs/applications/misc/trenchbroom/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ stdenv.mkDerivation rec {
--subst-var-by APP_VERSION_YEAR ${lib.versions.major version} \
--subst-var-by APP_VERSION_NUMBER ${lib.versions.minor version} \
--subst-var-by GIT_DESCRIBE v${version}

# Tests don't compile because of vendored `catch2` being incompatible with glibc-2.34.
# Also, no need to since we don't even run them.
substituteInPlace lib/CMakeLists.txt \
--replace "add_subdirectory(Catch2)" ""
substituteInPlace lib/vecmath/CMakeLists.txt \
--replace "add_subdirectory(test)" "" \
--replace "add_subdirectory(lib)" ""
substituteInPlace lib/kdl/CMakeLists.txt \
--replace "add_subdirectory(test)" ""
substituteInPlace common/CMakeLists.txt \
--replace "add_subdirectory(test)" "" \
--replace "add_subdirectory(benchmark)" ""
'';

nativeBuildInputs = [ cmake git pandoc wrapQtAppsHook copyDesktopItems ];
Expand Down
5 changes: 5 additions & 0 deletions pkgs/applications/science/logic/potassco/clingcon.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, fetchFromGitHub
, cmake
, clingo
, catch2
}:

stdenv.mkDerivation rec {
Expand All @@ -15,6 +16,10 @@ stdenv.mkDerivation rec {
sha256 = "1g2xkz9nsgqnrw3fdf5jchl16f0skj5mm32va61scc2yrchll166";
};

postPatch = ''
cp ${catch2}/include/catch2/catch.hpp libclingcon/tests/catch.hpp
'';

nativeBuildInputs = [ cmake clingo ];

cmakeFlags = [
Expand Down
8 changes: 8 additions & 0 deletions pkgs/applications/version-management/rcs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ stdenv.mkDerivation rec {
sha256 = "sha256-Q93+EHJKi4XiRo9kA7YABzcYbwHmDgvWL95p2EIjTMU=";
};

patches = [
# glibc 2.34 compat
(fetchpatch {
url = "https://src.fedoraproject.org/rpms/rcs/raw/f8e07cd37f4abfb36e37d41852bb8f9e234d3fb1/f/rcs-5.10.0-SIGSTKSZ.patch";
sha256 = "sha256-mc6Uye9mdEsLBcOnf1m1TUb1BV0ncNU//iKBpLGBjho=";
})
];

ac_cv_path_ED = "${ed}/bin/ed";
DIFF = "${diffutils}/bin/diff";
DIFF3 = "${diffutils}/bin/diff3";
Expand Down
1 change: 1 addition & 0 deletions pkgs/applications/video/quvi/library.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ stdenv.mkDerivation rec {
license = lib.licenses.lgpl21Plus;
platforms = lib.platforms.linux;
maintainers = [ ];
broken = true; # missing glibc-2.34 support, no upstream activity
};
}
1 change: 1 addition & 0 deletions pkgs/applications/video/quvi/scripts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ stdenv.mkDerivation rec {
license = lib.licenses.lgpl21Plus;
platforms = lib.platforms.linux;
maintainers = [ ];
broken = true; # missing glibc-2.34 support, no upstream activity
};
}
1 change: 1 addition & 0 deletions pkgs/applications/video/quvi/tool.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ stdenv.mkDerivation rec {
license = lib.licenses.lgpl21Plus;
platforms = lib.platforms.linux;
maintainers = [ ];
broken = true; # missing glibc-2.34 support, no upstream activity
};
}
4 changes: 2 additions & 2 deletions pkgs/development/compilers/gcc/10/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ let majorVersion = "10";

inherit (stdenv) buildPlatform hostPlatform targetPlatform;

patches =
optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
patches = [ ./gcc10-asan-glibc-2.34.patch ]
++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
++ optional noSysDirs ../no-sys-dirs.patch
++ optional (noSysDirs && hostPlatform.isRiscV) ../no-sys-dirs-riscv.patch
/* ++ optional (hostPlatform != buildPlatform) (fetchpatch { # XXX: Refine when this should be applied
Expand Down
70 changes: 70 additions & 0 deletions pkgs/development/compilers/gcc/10/gcc10-asan-glibc-2.34.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
From 950bac27d63c1c2ac3a6ed867692d6a13f21feb3 Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
Date: Sat, 17 Apr 2021 11:27:14 +0200
Subject: [PATCH] sanitizer: Fix asan against glibc 2.34 [PR100114]

As mentioned in the PR, SIGSTKSZ is no longer a compile time constant in
glibc 2.34 and later, so
static const uptr kAltStackSize = SIGSTKSZ * 4;
needs dynamic initialization, but is used by a function called indirectly
from .preinit_array and therefore before the variable is constructed.
This results in using 0 size instead and all asan instrumented programs
die with:
==91==ERROR: AddressSanitizer failed to allocate 0x0 (0) bytes of SetAlternateSignalStack (error code: 22)

Here is a cherry-pick from upstream to fix this.

2021-04-17 Jakub Jelinek <jakub@redhat.com>

PR sanitizer/100114
* sanitizer_common/sanitizer_posix_libcdep.cpp: Cherry-pick
llvm-project revisions 82150606fb11d28813ae6da1101f5bda638165fe
and b93629dd335ffee2fc4b9b619bf86c3f9e6b0023.

(cherry picked from commit d9f462fb372fb02da032cefd6b091d7582c425ae)
---
.../sanitizer_common/sanitizer_posix_libcdep.cpp | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp
index 304b3a01a08..ac88fbe074e 100644
--- a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp
+++ b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp
@@ -169,7 +169,11 @@ bool SupportsColoredOutput(fd_t fd) {

#if !SANITIZER_GO
// TODO(glider): different tools may require different altstack size.
-static const uptr kAltStackSize = SIGSTKSZ * 4; // SIGSTKSZ is not enough.
+static uptr GetAltStackSize() {
+ // SIGSTKSZ is not enough.
+ static const uptr kAltStackSize = SIGSTKSZ * 4;
+ return kAltStackSize;
+}

void SetAlternateSignalStack() {
stack_t altstack, oldstack;
@@ -180,10 +184,9 @@ void SetAlternateSignalStack() {
// TODO(glider): the mapped stack should have the MAP_STACK flag in the
// future. It is not required by man 2 sigaltstack now (they're using
// malloc()).
- void* base = MmapOrDie(kAltStackSize, __func__);
- altstack.ss_sp = (char*) base;
+ altstack.ss_size = GetAltStackSize();
+ altstack.ss_sp = (char *)MmapOrDie(altstack.ss_size, __func__);
altstack.ss_flags = 0;
- altstack.ss_size = kAltStackSize;
CHECK_EQ(0, sigaltstack(&altstack, nullptr));
}

@@ -191,7 +194,7 @@ void UnsetAlternateSignalStack() {
stack_t altstack, oldstack;
altstack.ss_sp = nullptr;
altstack.ss_flags = SS_DISABLE;
- altstack.ss_size = kAltStackSize; // Some sane value required on Darwin.
+ altstack.ss_size = GetAltStackSize(); // Some sane value required on Darwin.
CHECK_EQ(0, sigaltstack(&altstack, &oldstack));
UnmapOrDie(oldstack.ss_sp, oldstack.ss_size);
}
--
2.27.0

3 changes: 3 additions & 0 deletions pkgs/development/compilers/gcc/7/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ let majorVersion = "7";
./riscv-pthread-reentrant.patch
# https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00297.html
./riscv-no-relax.patch
# Fix for asan w/glibc-2.34. Although there's no upstream backport to v7,
# the patch from gcc 8 seems to work perfectly fine.
./gcc8-asan-glibc-2.34.patch

./0001-Fix-build-for-glibc-2.31.patch
]
Expand Down
70 changes: 70 additions & 0 deletions pkgs/development/compilers/gcc/7/gcc8-asan-glibc-2.34.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
From ef195a39d0d3b929cc676302d074b42c25460601 Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
Date: Sat, 17 Apr 2021 11:27:14 +0200
Subject: [PATCH] sanitizer: Fix asan against glibc 2.34 [PR100114]

As mentioned in the PR, SIGSTKSZ is no longer a compile time constant in
glibc 2.34 and later, so
static const uptr kAltStackSize = SIGSTKSZ * 4;
needs dynamic initialization, but is used by a function called indirectly
from .preinit_array and therefore before the variable is constructed.
This results in using 0 size instead and all asan instrumented programs
die with:
==91==ERROR: AddressSanitizer failed to allocate 0x0 (0) bytes of SetAlternateSignalStack (error code: 22)

Here is a cherry-pick from upstream to fix this.

2021-04-17 Jakub Jelinek <jakub@redhat.com>

PR sanitizer/100114
* sanitizer_common/sanitizer_posix_libcdep.cc: Cherry-pick
llvm-project revisions 82150606fb11d28813ae6da1101f5bda638165fe
and b93629dd335ffee2fc4b9b619bf86c3f9e6b0023.

(cherry picked from commit 950bac27d63c1c2ac3a6ed867692d6a13f21feb3)
---
.../sanitizer_common/sanitizer_posix_libcdep.cc | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc
index 1a37118c299..066079b3954 100644
--- a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cc
@@ -159,7 +159,11 @@ bool SupportsColoredOutput(fd_t fd) {

#if !SANITIZER_GO
// TODO(glider): different tools may require different altstack size.
-static const uptr kAltStackSize = SIGSTKSZ * 4; // SIGSTKSZ is not enough.
+static uptr GetAltStackSize() {
+ // SIGSTKSZ is not enough.
+ static const uptr kAltStackSize = SIGSTKSZ * 4;
+ return kAltStackSize;
+}

void SetAlternateSignalStack() {
stack_t altstack, oldstack;
@@ -170,10 +174,9 @@ void SetAlternateSignalStack() {
// TODO(glider): the mapped stack should have the MAP_STACK flag in the
// future. It is not required by man 2 sigaltstack now (they're using
// malloc()).
- void* base = MmapOrDie(kAltStackSize, __func__);
- altstack.ss_sp = (char*) base;
+ altstack.ss_size = GetAltStackSize();
+ altstack.ss_sp = (char *)MmapOrDie(altstack.ss_size, __func__);
altstack.ss_flags = 0;
- altstack.ss_size = kAltStackSize;
CHECK_EQ(0, sigaltstack(&altstack, nullptr));
}

@@ -181,7 +184,7 @@ void UnsetAlternateSignalStack() {
stack_t altstack, oldstack;
altstack.ss_sp = nullptr;
altstack.ss_flags = SS_DISABLE;
- altstack.ss_size = kAltStackSize; // Some sane value required on Darwin.
+ altstack.ss_size = GetAltStackSize(); // Some sane value required on Darwin.
CHECK_EQ(0, sigaltstack(&altstack, &oldstack));
UnmapOrDie(oldstack.ss_sp, oldstack.ss_size);
}
--
2.27.0

2 changes: 1 addition & 1 deletion pkgs/development/compilers/gcc/9/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ let majorVersion = "9";
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96796
#
# This patch can most likely be removed by a post 9.3.0-release.
[ ./avoid-cycling-subreg-reloads.patch ]
[ ./avoid-cycling-subreg-reloads.patch ./gcc9-asan-glibc-2.34.patch ]
++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch
++ optional targetPlatform.isNetBSD ../libstdc++-netbsd-ctypes.patch
++ optional noSysDirs ../no-sys-dirs.patch
Expand Down
Loading