From 10a4220c8ac24529241c891f2190edc0b69946e2 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 12 Mar 2026 00:26:05 -0400 Subject: [PATCH 1/3] spandsp: fix dead source URL, add mirror --- pkgs/development/libraries/spandsp/common.nix | 2 +- pkgs/development/libraries/spandsp/default.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/spandsp/common.nix b/pkgs/development/libraries/spandsp/common.nix index 1aacb0f1123f..3c320cedd9dd 100644 --- a/pkgs/development/libraries/spandsp/common.nix +++ b/pkgs/development/libraries/spandsp/common.nix @@ -220,6 +220,6 @@ stdenv.mkDerivation (finalAttrs: { maintainers = with lib.maintainers; [ misuzu ]; teams = [ lib.teams.ngi ]; license = lib.licenses.gpl2; - downloadPage = "http://www.soft-switch.org/downloads/spandsp/"; + downloadPage = "https://github.com/freeswitch/spandsp"; }; }) diff --git a/pkgs/development/libraries/spandsp/default.nix b/pkgs/development/libraries/spandsp/default.nix index 0a06b112e4c2..df1b5639bc47 100644 --- a/pkgs/development/libraries/spandsp/default.nix +++ b/pkgs/development/libraries/spandsp/default.nix @@ -7,7 +7,7 @@ (callPackage ./common.nix { }) rec { version = "0.0.6"; src = fetchurl { - url = "https://www.soft-switch.org/downloads/spandsp/spandsp-${version}.tar.gz"; + url = "https://src.fedoraproject.org/lookaside/pkgs/spandsp/spandsp-${version}.tar.gz/897d839516a6d4edb20397d4757a7ca3/spandsp-${version}.tar.gz"; sha256 = "0rclrkyspzk575v8fslzjpgp4y2s4x7xk3r55ycvpi4agv33l1fc"; }; patches = [ From 7dbd6409f86e98c6aec7479231b61797705319c5 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 12 Mar 2026 00:26:40 -0400 Subject: [PATCH 2/3] spandsp: fix bit_operations_tests UB on ppc64be --- pkgs/development/libraries/spandsp/common.nix | 3 ++ .../spandsp/fix-bit-operations-ub.patch | 53 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 pkgs/development/libraries/spandsp/fix-bit-operations-ub.patch diff --git a/pkgs/development/libraries/spandsp/common.nix b/pkgs/development/libraries/spandsp/common.nix index 3c320cedd9dd..c564d3da979e 100644 --- a/pkgs/development/libraries/spandsp/common.nix +++ b/pkgs/development/libraries/spandsp/common.nix @@ -40,6 +40,9 @@ stdenv.mkDerivation (finalAttrs: { # https://github.com/freeswitch/spandsp/pull/111 ./Fix-tests-pcap_parse-build-on-musl.patch + + # https://github.com/freeswitch/spandsp/pull/116 + ./fix-bit-operations-ub.patch ] ++ patches; diff --git a/pkgs/development/libraries/spandsp/fix-bit-operations-ub.patch b/pkgs/development/libraries/spandsp/fix-bit-operations-ub.patch new file mode 100644 index 000000000000..24562d6135d8 --- /dev/null +++ b/pkgs/development/libraries/spandsp/fix-bit-operations-ub.patch @@ -0,0 +1,53 @@ +From 6366823f4c6a1641543a0f3859afcafccf2e47af Mon Sep 17 00:00:00 2001 +From: Amaan Qureshi +Date: Wed, 11 Mar 2026 23:34:26 -0400 +Subject: [PATCH] tests: fix undefined behavior in `bit_operations_tests` + +The `most_significant_one32`/`least_significant_one32` test loop +started at `i = -1`, which produces a shift of `1U << -1`. This is +undefined behavior per the C standard, as the shift count must be in +`[0, bit_width)`. On x86 this happened to produce `0x80000000` due to +masking the shift count to 5 bits, but on ppc64be it produces `0`, +causing a spurious test failure. + +This commit starts the loop at `i = 0` instead. Testing the zero-input +case is not meaningful here since `most_significant_one32(0)` itself +invokes UB internally (`1 << top_bit(0)` where `top_bit` returns `-1`). +I've also fixed the printf format strings to use `1U` instead of `1` to +avoid signed overflow when `i = 31`. +--- + tests/bit_operations_tests.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tests/bit_operations_tests.c b/tests/bit_operations_tests.c +index 53cd997..53f7892 100644 +--- a/tests/bit_operations_tests.c ++++ b/tests/bit_operations_tests.c +@@ -257,22 +257,22 @@ int main(int argc, char *argv[]) + printf("Test failed: parity 8 - %x %x %x\n", i, ax, bx); + exit(2); + } + } + +- for (i = -1; i < 32; i++) ++ for (i = 0; i < 32; i++) + { + ax32 = most_significant_one32(1 << i); + if (ax32 != (1 << i)) + { +- printf("Test failed: most significant one 32 - %x %" PRIx32 " %x\n", i, ax32, (1 << i)); ++ printf("Test failed: most significant one 32 - %x %" PRIx32 " %x\n", i, ax32, (1U << i)); + exit(2); + } + ax32 = least_significant_one32(1 << i); + if (ax32 != (1 << i)) + { +- printf("Test failed: least significant one 32 - %x %" PRIx32 " %x\n", i, ax32, (1 << i)); ++ printf("Test failed: least significant one 32 - %x %" PRIx32 " %x\n", i, ax32, (1U << i)); + exit(2); + } + } + + for (i = 0x80000000; i < 0x800FFFFF; i++) +-- +2.53.0 From c4d7c303d311fe6ec7615a43671ae718bac019aa Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 12 Mar 2026 04:09:40 -0400 Subject: [PATCH 3/3] spandsp: disable `lpc10_tests` on ppc64 The LPC-10 test checks decoded audio against a reference WAV generated on x86. On POWER, small float rounding differences in the encoder accumulate over hundreds of frames and eventually produce different output, even though the codec itself works correctly. --- pkgs/development/libraries/spandsp/common.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/libraries/spandsp/common.nix b/pkgs/development/libraries/spandsp/common.nix index c564d3da979e..8ceab5257191 100644 --- a/pkgs/development/libraries/spandsp/common.nix +++ b/pkgs/development/libraries/spandsp/common.nix @@ -176,6 +176,10 @@ stdenv.mkDerivation (finalAttrs: { # Seemingly runs forever, with tons of output "v22bis_tests" + ] + ++ lib.optionals stdenv.hostPlatform.isPower64 [ + # Output differs from x86-generated reference due to float precision + "lpc10_tests" ]; checkPhase = ''