We use BusyBox within Alpine Linux 3.10 in a docker container. Today we found out, that the "wc" utility is counting wrong above a certain size. It looks to me like a overflow issue. Example on Ubuntu Linux (ok): # 1000 Byte (ok) cat /dev/zero | pv --stop-at-size -s 1000 | wc -c >> 1000 # 4 Gib (ok) cat /dev/zero | pv --stop-at-size -s 4294967296 | wc -c >> 4294967296 Example on Busybox (overflow at ~4 Gib): # 4 Gib minus 1 Byte (ok) cat /dev/zero | pv --stop-at-size -s 4294967295 | wc -c >> 4294967295 # 4 Gib (overflow) cat /dev/zero | pv --stop-at-size -s 4294967296 | wc -c >> 0
Code from: coreutils/wc.c #if ENABLE_FEATURE_WC_LARGE # define COUNT_T unsigned long long # define COUNT_FMT "llu" #else # define COUNT_T unsigned # define COUNT_FMT "u" #endif Can you enable this flag, so that the bigger variable type is used for counting?
FEATURE_WC_LARGE is enabled by default. It looks as though the Alpine Linux developers have turned it off in their build. If you want it enabled there you'd have to ask them.
Thanks for the pointer. The bug was fixed in https://gitlab.alpinelinux.org/alpine/aports alpine/aports$ git annotate main/busybox/busyboxconfig | grep WC_LARGE bcf80db9586 (Sören Tempel 2020-03-13 12:51:36 +0100 336)CONFIG_FEATURE_WC_LARGE=y git show bcf80db9586 ... @@ -333,7 +333,7 @@ CONFIG_UUDECODE=y CONFIG_BASE64=y CONFIG_UUENCODE=y CONFIG_WC=y -# CONFIG_FEATURE_WC_LARGE is not set +CONFIG_FEATURE_WC_LARGE=y I will try a newer version of alpine.
Bug is fixed in alpine >= 3.11.6.