From 3eca1c5500aa2477b078b9764949b1ef4bf0c117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Donval?= Date: Thu, 24 Aug 2017 15:34:23 +0100 Subject: [PATCH 1/2] Add patch to enable SIGBUS capture Kernels older than 3.18.6 emit SIGBUS signal upon stackoverflow instead of SIGSEGV. This patch enables the capture of SIGBUS (just as it is done on Darwin). Applying it fixes https://github.com/NixOS/nixpkgs/issues/6028 and https://github.com/NixOS/nixpkgs/issues/28464#issuecomment-324255704 --- pkgs/development/libraries/libsigsegv/sigbus_fix.patch | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 pkgs/development/libraries/libsigsegv/sigbus_fix.patch diff --git a/pkgs/development/libraries/libsigsegv/sigbus_fix.patch b/pkgs/development/libraries/libsigsegv/sigbus_fix.patch new file mode 100644 index 00000000000..6f1c399041d --- /dev/null +++ b/pkgs/development/libraries/libsigsegv/sigbus_fix.patch @@ -0,0 +1,8 @@ +--- a/src/signals.h 2017-08-23 14:07:05.000000000 +0100 ++++ b/src/signals.h 2017-08-23 14:06:53.000000000 +0100 +@@ -18,4 +18,4 @@ + /* List of signals that are sent when an invalid virtual memory address + is accessed, or when the stack overflows. */ + #define SIGSEGV_FOR_ALL_SIGNALS(var,body) \ +- { int var; var = SIGSEGV; { body } } ++ { int var; var = SIGSEGV; { body } var = SIGBUS; { body } } From eef236d0ba205b061972d55926a45b593a4c3d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Sun, 27 Aug 2017 17:21:35 +0200 Subject: [PATCH 2/2] libsigsegv*: add an option to apply a patch Close #28536; this code is a bit different in style for 2.5, and avoids mass rebuild for the default version. --- pkgs/development/libraries/libsigsegv/2.5.nix | 6 +++++- pkgs/development/libraries/libsigsegv/default.nix | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/libsigsegv/2.5.nix b/pkgs/development/libraries/libsigsegv/2.5.nix index 0712ba92f60..fd453defe71 100644 --- a/pkgs/development/libraries/libsigsegv/2.5.nix +++ b/pkgs/development/libraries/libsigsegv/2.5.nix @@ -1,4 +1,6 @@ -{ stdenv, fetchurl }: +{ stdenv, fetchurl +, enableSigbusFix ? false # required by kernels < 3.18.6 +}: stdenv.mkDerivation rec { name = "libsigsegv-2.5"; @@ -8,6 +10,8 @@ stdenv.mkDerivation rec { sha256 = "0fvcsq9msi63vrbpvks6mqkrnls5cfy6bzww063sqhk2h49vsyyg"; }; + patches = stdenv.lib.optional enableSigbusFix ./sigbus_fix.patch; + meta = { homepage = http://libsigsegv.sf.net; description = "A library for handling page faults in user mode"; diff --git a/pkgs/development/libraries/libsigsegv/default.nix b/pkgs/development/libraries/libsigsegv/default.nix index 961b3b2d883..8e1079bfbc8 100644 --- a/pkgs/development/libraries/libsigsegv/default.nix +++ b/pkgs/development/libraries/libsigsegv/default.nix @@ -1,5 +1,6 @@ { stdenv, fetchurl , buildPlatform, hostPlatform +, enableSigbusFix ? false # required by kernels < 3.18.6 }: stdenv.mkDerivation rec { @@ -10,6 +11,8 @@ stdenv.mkDerivation rec { sha256 = "063swdvq7mbmc1clv0rnh20grwln1zfc2qnm0sa1hivcxyr2wz6x"; }; + patches = if enableSigbusFix then [ ./sigbus_fix.patch ] else null; + doCheck = hostPlatform == buildPlatform; meta = {