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

[Bug]: cksum in coreutils fails with write error #11912

Closed
fancsali opened this issue Sep 13, 2022 · 6 comments · Fixed by #12182
Closed

[Bug]: cksum in coreutils fails with write error #11912

fancsali opened this issue Sep 13, 2022 · 6 comments · Fixed by #12182
Labels
arch-arm Issue reproducible on packages compiled for ARM arch-i686 Issue reproducible on packages compiled for i686 bug report Something is not working properly

Comments

@fancsali
Copy link

fancsali commented Sep 13, 2022

Problem description

Calling cksum from the coreutils package seems to try to call write() twice emitting the expected output but then also an error message and a non 0 return code.

What steps will reproduce the bug?

Pipe any file to cksum:

touch foo
$ cksum < foo
4294967295 0
cksum: write error: Bad address
$ echo $?
1

What is the expected behavior?

The call should only return the sum and the file size and no error message/code:

touch foo
$ cksum < foo
4294967295 0

Further information

Calling the busybox version of the tool works fine:

busybox cksum < foo
4294967295 0

Also, the version numbers of the packages in question:

$ apt list | egrep 'coreutils|busybox'

busybox/stable,now 1.35.0-2 arm [installed]
coreutils/stable,now 9.1 arm [installed]

System information

termux-info:

Termux Variables:
unsupported
Packages CPU architecture:
arm
Subscribed repositories:
# sources.list
deb https://packages.termux.dev/apt/termux-main stable main
Updatable packages:
All packages up to date
termux-tools version:
1.29.2
Android version:
9
Kernel build information:
Linux localhost 4.19.122-09121-gd58e3f311e19 #1 SMP PREEMPT Wed Aug 19 00:35:31 PDT 2020 armv7l Android
Device manufacturer:
Google
Device model:
ASUS Chromebook Flip C100PA
@fancsali fancsali added the bug report Something is not working properly label Sep 13, 2022
@licy183
Copy link
Member

licy183 commented Sep 13, 2022

I can reproduce it on arm/i686, but not on aarch64/x86_64.

@fancsali
Copy link
Author

I can reproduce it on arm/i686, but not on aarch64/x86_64.

Had a look myself, and sounds about right.

  • On my newer 64-bit ARM Android phone, it's working fine
  • On the older 32-bit ARM Chromebook it's buggy

Haven't had a chance to try it on architectures other than ARM, though.

@xtkoba
Copy link
Contributor

xtkoba commented Sep 14, 2022

I believe this has the same root cause as #9056 (which is in fact not resolved but just worked around), suspecting a bug in Gnulib.

@xtkoba xtkoba added arch-arm Issue reproducible on packages compiled for ARM arch-i686 Issue reproducible on packages compiled for i686 labels Sep 14, 2022
@fancsali
Copy link
Author

I believe this has the same root cause as #9056 (which is in fact not resolved but just worked around), suspecting a bug in Gnulib.

Not sure what that means in this context: so how do we mitigate this?

@xtkoba
Copy link
Contributor

xtkoba commented Sep 28, 2022

I think I have finally found the bug in Gnulib:

--- a/lib/stdio-impl.h
+++ b/lib/stdio-impl.h
@@ -68,8 +68,10 @@
 # elif defined __ANDROID__ /* Android */
 #  ifdef __LP64__
 #   define _gl_flags_file_t int
+#   define _gl_struct_file_off_t int64_t
 #  else
 #   define _gl_flags_file_t short
+#   define _gl_struct_file_off_t __kernel_off_t
 #  endif
   /* Up to this commit from 2015-10-12
      <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
@@ -96,7 +98,7 @@
                          unsigned char _nbuf[1]; \
                          struct { unsigned char *_base; size_t _size; } _lb; \
                          int _blksize; \
-                         fpos_t _offset; \
+                         _gl_struct_file_off_t _offset; \
                          /* More fields, not relevant here.  */ \
                        } *) fp)
 # else

@Grimler91
Copy link
Member

@xtkoba thanks for investigating and fixing the core issue! Do you want to report it to the gnulib developers? Otherwise I can do it, would be nice to get the fix upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-arm Issue reproducible on packages compiled for ARM arch-i686 Issue reproducible on packages compiled for i686 bug report Something is not working properly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants