Artix Linux Forum

Artix Linux => System => Topic started by: Lancia on 27 August 2023, 13:04:45

Title: [SOLVED] Running "wc -l" command from GNU coreutils core dumps because of SIGILL
Post by: Lancia on 27 August 2023, 13:04:45
As the title suggests, for some reason when I run the "wc -l" command that belongs to GNU coreutils, I get a core dump because of a SIGILL (illegal instruction). All other options seem to be fine except for "-l":
Code: [Select]
$ 0: for option in c m l L w; do echo -n "-$option: "; dd if=/dev/urandom count=5 2>/dev/null | wc -$option; done
-c: 2560
-m: 1367
-l: Illegal instruction (core dumped)
-L: 143
-w: 54

What is weirder is that in combination with other options, it works as expected:
Code: [Select]
$ 0: dd if=/dev/urandom count=5 2>/dev/null | wc -c -m -l -L -w
      8      52    1366    2560     145

Here is strace output for GNU "wc -l": https://paste.artixlinux.org/view/c4f6bd60

I've also installed busybox from Arch repos and "wc -l" works fine, so right now I am using it as my main wc command.

I've also tried searching the forums about my problem, but nothing came up.

What I really want to know is if anybody else has this problem, or is it just me?
Title: Re: Running "wc -l" command from GNU coreutils core dumps because of SIGILL
Post by: ncmprhnsbl on 29 August 2023, 04:22:03
i noticed this:
Quote
Sat Aug 26 21:01:45 UTC 2023
a/coreutils-9.3-x86_64-2.txz:  Rebuilt.
  Don't support AVX2 instructions for wc. Since it's possible to enable a
  kernel option that causes the kernel to advertise AVX2 as available, but
  leads to an illegal instruction if there's an attempt to actually use
  AVX2 when old microcode is in use, this isn't reliable. Furthermore, wc
  is used by the pkgtools and this sort of failure could lead to corruption
  of the filesystem and/or package database. So, we'll disable this to be on
  the safe side. Thanks to lancsuk for noticing this issue.
in the Slackware current changelog : http://ftp.slackware.com/pub/slackware/slackware64-current/ChangeLog.txt
this is the patch used:
Code: [Select]
--- ./src/wc.c.orig	2023-04-10 05:14:08.000000000 -0500
+++ ./src/wc.c 2023-08-26 14:22:10.058092456 -0500
@@ -174,14 +174,7 @@
 
   if (avx_enabled)
     {
-      eax = ebx = ecx = edx = 0;
-      if (! __get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx))
-        getcpuid_ok = false;
-      else
-        {
-          if (! (ebx & bit_AVX2))
-            avx_enabled = false;  /* Hardware doesn't support it.  */
-        }
+        avx_enabled = false;  /* Never use AVX2. */
     }
 
 
i also see that arch have removed all their patches, while the artix package still retains them..
fwiw, on obarun atm, which uses arch's coreutils, it seems to work fine:
Code: [Select]
for option in c m l L w; do echo -n "-$option: "; dd if=/dev/urandom count=5 2>/dev/null | wc -$option; done
-c: 2560
-m: 1379
-l: 7
-L: 151
-w: 60

EDIT: now checked in artix, and wc -l works fine..   looking again at the slackware thing, i guess it may require a specific hardware/microcode/kernel combination, that i don't have.
Title: Re: Running "wc -l" command from GNU coreutils core dumps because of SIGILL
Post by: Lancia on 01 October 2023, 17:48:03
Problem is fixed now, GNU coreutils "wc -l" no longer core dumps.

Special thanks to Artix team, marking as solved.