[Bug 258156] databases/mysql80-server: Illegal instruction when building 8.0.26 on Penryn in routerfuzz_router_uri, FreeBSD 12.2 amd64

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 29 Aug 2021 23:05:56 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258156

            Bug ID: 258156
           Summary: databases/mysql80-server: Illegal instruction when
                    building 8.0.26 on Penryn in routerfuzz_router_uri,
                    FreeBSD 12.2 amd64
           Product: Ports & Packages
           Version: Latest
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: joneum@FreeBSD.org
          Reporter: bhtooefr@bhtooefr.org
             Flags: maintainer-feedback?(joneum@FreeBSD.org)
          Assignee: joneum@FreeBSD.org

Created attachment 227543
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=227543&action=edit
mysql80-server 8.0.26 build output

I'm finding that on my FreeBSD 12.2-RELEASE-p7 amd64 system with dual Xeon
L5420s (Harpertown, which is Penryn microarchitecture), I'm unable to build
mysql80-server, as a SIGILL is thrown running routerfuzz_router_uri. I've tried
MAKE_JOBS_UNSAFE=yes with no changes, as well as adding CPUTYPE?=penryn to
/etc/make.conf.

I've attached the output from make trying to build the port.

After rebuilding the routerfuzz_router_uri binary that's deleted, and running
gdb on the core dump, I receive the following:

root@uncannyvalley:/usr/ports/databases/mysql80-server/work/.build/router/tests/fuzzers
# gdb core routerfuzz_router_u.core
GNU gdb (GDB) 10.2 [GDB v10.2 for FreeBSD]
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd12.2".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
core: No such file or directory.
[New LWP 101492]
Core was generated by `./routerfuzz_router_uri -merge=1 -verbosity=0
-merge_control_file=/usr/ports/dat'.
Program terminated with signal SIGILL, Illegal instruction.
#0  0x00000000002554f0 in ?? ()
(gdb) file routerfuzz_router_uri
warning: core file may not match specified executable file.
Reading symbols from routerfuzz_router_uri...
(gdb) disassemble
Dump of assembler code for function __sanitizer_cov_trace_const_cmp1(uint8_t,
uint8_t):
   0x00000000002554e0 <+0>:     push   %rbp
   0x00000000002554e1 <+1>:     mov    %rsp,%rbp
   0x00000000002554e4 <+4>:     mov    0x8(%rbp),%rax
   0x00000000002554e8 <+8>:     mov    %esi,%ecx
   0x00000000002554ea <+10>:    xor    %dil,%cl
   0x00000000002554ed <+13>:    movzbl %cl,%ecx
=> 0x00000000002554f0 <+16>:    popcnt %rcx,%rcx
   0x00000000002554f5 <+21>:    cmp    %sil,%dil
   0x00000000002554f8 <+24>:    jne    0x2554ff
<__sanitizer_cov_trace_const_cmp1(uint8_t, uint8_t)+31>
   0x00000000002554fa <+26>:    xor    %r9d,%r9d
   0x00000000002554fd <+29>:    jmp    0x255516
<__sanitizer_cov_trace_const_cmp1(uint8_t, uint8_t)+54>
   0x00000000002554ff <+31>:    movzbl %dil,%edx
   0x0000000000255503 <+35>:    movzbl %sil,%esi
   0x0000000000255507 <+39>:    sub    %rsi,%rdx
   0x000000000025550a <+42>:    bsr    %rdx,%r9
   0x000000000025550e <+46>:    xor    $0x3f,%r9
   0x0000000000255512 <+50>:    add    $0x1,%r9
   0x0000000000255516 <+54>:    mov    %rax,%rsi
   0x0000000000255519 <+57>:    shl    $0x7,%rsi
   0x000000000025551d <+61>:    add    %eax,%eax
   0x000000000025551f <+63>:    and    $0x3fe,%eax
   0x0000000000255524 <+68>:    lea    0x4dad5(%rip),%r8        # 0x2a3000
<_ZN6fuzzer3TPCE>
   0x000000000025552b <+75>:    mov    $0x1,%edi
   0x0000000000255530 <+80>:    mov    $0x1,%edx
   0x0000000000255535 <+85>:    shl    %cl,%rdx
   0x0000000000255538 <+88>:    or     %rdx,0x31800(%r8,%rax,8)
   0x0000000000255540 <+96>:    lea    (%r9,%rsi,1),%rcx
   0x0000000000255544 <+100>:   add    $0x40,%rcx
   0x0000000000255548 <+104>:   mov    %rcx,%rax
   0x000000000025554b <+107>:   shr    $0x3,%rax
   0x000000000025554f <+111>:   shl    %cl,%rdi
   0x0000000000255552 <+114>:   and    $0x1ff8,%eax
   0x0000000000255557 <+119>:   or     %rdi,0x31800(%rax,%r8,1)
   0x000000000025555f <+127>:   pop    %rbp
   0x0000000000255560 <+128>:   ret
End of assembler dump.
(gdb)

popcnt is a Nehalem instruction, which obviously my Penryn CPU wouldn't have.
Looks like __sanitizer_cov_trace_const_cmp1 is a clang function - this may
actually be a clang bug (at least as FreeBSD supplies it), but we'll go with
mysql80-server as being the problem right now because that's the only thing I
can't build.

And my current /etc/make.conf:

WITH_PKGNG=     yes
DEFAULT_VERSIONS+=ssl=openssl
MAKE_JOBS_NUMBER=9
#MAKE_JOBS_UNSAFE=yes
OPTIONS_UNSET=  GSSAPI_BASE
OPTIONS_SET=    GSSAPI_MIT
CPUTYPE?=       penryn

And, for completeness, compiler info:

root@uncannyvalley:/usr/ports/databases/mysql80-server/work/.build/router/tests/fuzzers
# c++ --version
FreeBSD clang version 10.0.1 (git@github.com:llvm/llvm-project.git
llvmorg-10.0.1-0-gef32c611aa2)
Target: x86_64-unknown-freebsd12.2
Thread model: posix
InstalledDir: /usr/bin
root@uncannyvalley:/usr/ports/databases/mysql80-server/work/.build/router/tests/fuzzers
# which c++
/usr/bin/c++

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