Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Aug 2024 18:10:13 +0000
From:      bugzilla-noreply@freebsd.org
To:        ports-bugs@FreeBSD.org
Subject:   [Bug 281081] sysutils/ncdu2: Illegal instruction on some machines (amd64)
Message-ID:  <bug-281081-7788@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D281081

            Bug ID: 281081
           Summary: sysutils/ncdu2: Illegal instruction on some machines
                    (amd64)
           Product: Ports & Packages
           Version: Latest
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: sunpoet@FreeBSD.org
          Reporter: hpaluch@seznam.cz
             Flags: maintainer-feedback?(sunpoet@FreeBSD.org)
          Assignee: sunpoet@FreeBSD.org

Latest ncdu2 package (tested 2.4_1/amd64) is optimized for build server (th=
at
is default behavior of Zig compiler) and thus it causes "Illegal instruction
error" on some CPUs.

How to reproduce:

$ freebsd-version=20

14.1-RELEASE-p3

$ dmesg | fgrep CPU:

CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ (2000.12-MHz K8-class C=
PU)

$ doas pkg install ncdu2

$ pkg info | fgrep ncdu2

ncdu2-2.4_1                    NCurses Disk Usage (stable version written in
Zig)


$ ncdu2

Illegal instruction (core dumped)



To get illegal instruction opcode we can use gdb:

gdb /usr/local/bin/ncdu2=20
GNU gdb (GDB) 14.1 [GDB v14.1 for FreeBSD]
...
(gdb) run
Starting program: /usr/local/bin/ncdu2=20

Program received signal SIGILL, Illegal instruction.
Privileged opcode.
0x00000000010a5c17 in ?? ()
(gdb) bt
#0  0x00000000010a5c17 in ?? ()
#1  0x0000000001060f54 in ?? ()
#2  0x0000000001057ab3 in ?? ()
#3  0x000000000104ff44 in ?? ()
#4  0x000000000104fc9c in ?? ()
#5  0x0000000801300a6a in __libc_start1 () from /lib/libc.so.7
#6  0x000000000104fa20 in ?? ()

(gdb) x/4i 0x00000000010a5c17
=3D> 0x10a5c17:   vpxor  %xmm0,%xmm0,%xmm0
   0x10a5c1b:   vmovdqa %ymm0,0xa0(%rsp)
   0x10a5c24:   mov    %rax,0x120(%rsp)
   0x10a5c2c:   mov    0x118(%rsp),%rax


There are some references on Internet that (v)pxor requires AVX2 set, but I=
 was
uanble to find authoritative source.

Cause: Zig compiler always produces binary optimized for CPU on build server
unless instructed otherwise.

Workaround: pass "-Dcpu=3Dx86_64" to Zig compiler - it should produce gener=
ic
amd64 binary.

Here are details of my CPU from dmesg:

CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ (2000.12-MHz K8-class C=
PU)
  Origin=3D"AuthenticAMD"  Id=3D0x40fb2  Family=3D0xf  Model=3D0x4b  Steppi=
ng=3D2
=20
Features=3D0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,=
MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
  Features2=3D0x2001<SSE3,CX16>
  AMD Features=3D0xea500800<SYSCALL,NX,MMX+,FFXSR,RDTSCP,LM,3DNow!+,3DNow!>
  AMD Features2=3D0x1f<LAHF,CMP,SVM,ExtAPIC,CR8>
  SVM: NAsids=3D64

Same Illegal instruction error also occurs on another PC with "Intel(R)
Celeron(R) CPU N3450 @ 1.10GHz" (ZOTAC CI327 Nano )

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-281081-7788>