GNU bug report logs - #76360
cksum crc broken with VMULL on musl

Previous Next

Package: coreutils;

Reported by: Alyssa Ross <hi <at> alyssa.is>

Date: Mon, 17 Feb 2025 09:27:01 UTC

Severity: normal

Tags: fixed

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 76360 in the body.
You can then email your comments to 76360 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#76360; Package coreutils. (Mon, 17 Feb 2025 09:27:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alyssa Ross <hi <at> alyssa.is>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Mon, 17 Feb 2025 09:27:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alyssa Ross <hi <at> alyssa.is>
To: bug-coreutils <at> gnu.org
Subject: cksum crc broken with VMULL on musl
Date: Mon, 17 Feb 2025 10:26:15 +0100
[Message part 1 (text/plain, inline)]
On aarch64-unknown-linux-musl, cksum -a crc seems to be producing the
wrong values with coreutils 9.6, causing tests/cksum/cksum.sh to fail.
I bisected this to the following commit:

commit d155be4a22cdc5d271a74c2ae8226c4239ab76ed (HEAD)
Author: Sam Russell <sam.h.russell <at> gmail.com>
Date:   Thu Nov 28 20:28:21 2024 +0100

    cksum: use ARMv8 SIMD extensions
    
    * configure.ac: Add check for ARMv8 VMULL support.
    * src/cksum.c: Add ARMv8 VMULL detection function.
    * src/cksum.h: Add ARMv8 VMULL implementation declaration.
    * src/cksum_vmull.c: ARMv8 VMULL implementation.
    * src/local.mk: Add build flags for ARMv8 VMULL.
    * NEWS: Mention the ARMv8 SIMD improvement.

If I configure with utils_cv_vmull_intrinsic_exists=no the test passes.
Relevant portion of test-suite.log follows.  I think the "missing: No
such file or directory" is an unrelated incorrect use of the _returns
function?

FAIL: tests/cksum/cksum
=======================

cksum: missing: No such file or directory
--- exp	2025-02-17 09:18:57.198429856 +0000
+++ out	2025-02-17 09:18:57.198429856 +0000
@@ -1 +1 @@
-3720986905 65574 in
+2108650022 65574 in
--- exp	2025-02-17 09:18:57.202429997 +0000
+++ out	2025-02-17 09:18:57.202429997 +0000
@@ -1 +1 @@
-4278270357 65664 in
+1411087274 65664 in
FAIL tests/cksum/cksum.sh (exit status: 1)
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#76360; Package coreutils. (Mon, 17 Feb 2025 10:07:01 GMT) Full text and rfc822 format available.

Message #8 received at 76360 <at> debbugs.gnu.org (full text, mbox):

From: Alyssa Ross <hi <at> alyssa.is>
To: 76360 <at> debbugs.gnu.org
Subject: [PATCH] cksum: fix shift count overflow
Date: Mon, 17 Feb 2025 11:05:49 +0100
This fixes the following warnings when building for a platform where
uint_fast32_t is 32 bits:

src/cksum_vmull.c: In function 'cksum_vmull':
src/cksum_vmull.c:95:69: warning: left shift count >= width of type [-Wshift-count-overflow]
   95 |           xor_crc = vcombine_u64 (vcreate_u64 (0), vcreate_u64 (crc << 32));
      |                                                                     ^~
src/cksum_vmull.c:196:69: warning: left shift count >= width of type [-Wshift-count-overflow]
  196 |           xor_crc = vcombine_u64 (vcreate_u64 (0), vcreate_u64 (crc << 32));
      |                                                                     ^~

This resulted in cksum -a crc producing incorrect values on musl.
---
 src/cksum_vmull.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/cksum_vmull.c b/src/cksum_vmull.c
index c6f067584..6a87a21ab 100644
--- a/src/cksum_vmull.c
+++ b/src/cksum_vmull.c
@@ -92,7 +92,7 @@ cksum_vmull (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out)
           data = bswap_neon (data);
           /* XOR in initial CRC value (for us 0 so no effect), or CRC value
              calculated for previous BUFLEN buffer from fread */
-          xor_crc = vcombine_u64 (vcreate_u64 (0), vcreate_u64 (crc << 32));
+          xor_crc = vcombine_u64 (vcreate_u64 (0), vcreate_u64 ((uint64_t)crc << 32));
           crc = 0;
           data = veorq_u64 (data, xor_crc);
           data3 = vld1q_u64 ((uint64_t *) (datap + 1));
@@ -193,7 +193,7 @@ cksum_vmull (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out)
         {
           data = vld1q_u64 ((uint64_t *) (datap));
           data = bswap_neon (data);
-          xor_crc = vcombine_u64 (vcreate_u64 (0), vcreate_u64 (crc << 32));
+          xor_crc = vcombine_u64 (vcreate_u64 (0), vcreate_u64 ((uint64_t)crc << 32));
           crc = 0;
           data = veorq_u64 (data, xor_crc);
           while (bytes_read >= 32)

base-commit: d155be4a22cdc5d271a74c2ae8226c4239ab76ed
-- 
2.47.2





Information forwarded to bug-coreutils <at> gnu.org:
bug#76360; Package coreutils. (Mon, 17 Feb 2025 10:35:02 GMT) Full text and rfc822 format available.

Message #11 received at 76360 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Alyssa Ross <hi <at> alyssa.is>
Cc: 76360 <at> debbugs.gnu.org
Subject: Re: bug#76360: cksum crc broken with VMULL on musl
Date: Mon, 17 Feb 2025 02:34:11 -0800
[Message part 1 (text/plain, inline)]
Thanks for the bug report. I installed the attached patches; please give 
them a try, as I don't have easy access to that platform.
[0001-cksum-fix-test-for-missing.patch (text/x-patch, attachment)]
[0002-cksum-port-to-32-bit-uint_fast32_t.patch (text/x-patch, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#76360; Package coreutils. (Mon, 17 Feb 2025 11:00:02 GMT) Full text and rfc822 format available.

Message #14 received at 76360 <at> debbugs.gnu.org (full text, mbox):

From: Alyssa Ross <hi <at> alyssa.is>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 76360 <at> debbugs.gnu.org
Subject: Re: bug#76360: cksum crc broken with VMULL on musl
Date: Mon, 17 Feb 2025 11:59:05 +0100
[Message part 1 (text/plain, inline)]
Paul Eggert <eggert <at> cs.ucla.edu> writes:

> Thanks for the bug report. I installed the attached patches; please give 
> them a try, as I don't have easy access to that platform.

Both patches do what they're supposed to, thanks!
[signature.asc (application/pgp-signature, inline)]

Added tag(s) fixed. Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Mon, 17 Feb 2025 18:10:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 76360 <at> debbugs.gnu.org and Alyssa Ross <hi <at> alyssa.is> Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Mon, 17 Feb 2025 18:10:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 18 Mar 2025 11:24:39 GMT) Full text and rfc822 format available.

This bug report was last modified 152 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.