Bug 247288 - devel/stack: Crashes
Summary: devel/stack: Crashes
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-haskell (Nobody)
URL:
Keywords: crash, needs-qa
Depends on:
Blocks:
 
Reported: 2020-06-15 20:13 UTC by pmueller@occsilva.de
Modified: 2020-07-06 09:31 UTC (History)
5 users (show)

See Also:
arrowd: maintainer-feedback+
arrowd: merge-quarterly?


Attachments
dimes.boot output text (9.82 KB, text/plain)
2020-06-19 10:59 UTC, pmueller@occsilva.de
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description pmueller@occsilva.de 2020-06-15 20:13:41 UTC
Have a core dump with stack

My CPU

CPU: AMD Turion(tm) II Neo N40L Dual-Core Processor (1497.54-MHz K8-class CPU)
  Origin="AuthenticAMD"  Id=0x100f63  Family=0x10  Model=0x6  Stepping=3
  Features=0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
  Features2=0x802009<SSE3,MON,CX16,POPCNT>
  AMD Features=0xee500800<SYSCALL,NX,MMX+,FFXSR,Page1GB,RDTSCP,LM,3DNow!+,3DNow!>
  AMD Features2=0x837ff<LAHF,CMP,SVM,ExtAPIC,CR8,ABM,SSE4A,MAS,Prefetch,OSVW,IBS,SKINIT,WDT,NodeId>
  SVM: NP,NRIP,NAsids=64
  TSC: P-state invariant
real memory  = 6442450944 (6144 MB)
avail memory = 6047748096 (5767 MB)
Event timer "LAPIC" quality 400
ACPI APIC Table: <HP     ProLiant>
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
FreeBSD/SMP: 1 package(s) x 2 core(s)
Comment 1 daniel.engberg.lists 2020-06-15 20:29:10 UTC
You need a provide more information and I presume you mean devel/stack.

OS (including version), are you using official packages, self-compiled or ports? 

As far as I can tell (lib)gmp seems to be linked at least according to https://www.freshports.org/devel/stack so it might be worth having a look at as it might have some issues on very old CPUs.

If its one of the last two, do you have assembly enabled in (lib)gmp and if so does it work if you disable it (you need to recompile all packages depending on it not just stack)?

Did a previous version work and if so which one?
Comment 2 pmueller@occsilva.de 2020-06-16 05:36:41 UTC
My system: FreeBSD 12.1-RELEASE-p5 FreeBSD 12.1-RELEASE-p5 GENERIC  amd64

>I presume you mean devel/stack
yes

I'm using packages.

pkg info | grep hs-                      
hs-pandoc-2.9.2                Conversion between markup formats
hs-stack-2.1.3.1               Cross-platform program for developing Haskell programs

>Did a previous version work and if so which one?
Haven't used it before. First time use of the package.
Comment 3 Kubilay Kocak freebsd_committer freebsd_triage 2020-06-16 06:22:09 UTC
Could you please include:

- Details of what command/program/actions reproduce the crash
- pkg version -v output (as an attachment)
- var/run/dmesg.boot output (as an attachment)
- Summary and backtrace of the crash (using gdb)
Comment 4 pmueller@occsilva.de 2020-06-19 10:59:07 UTC
Created attachment 215771 [details]
dimes.boot output text

dimes.boot output text
Comment 5 pmueller@occsilva.de 2020-06-19 11:01:18 UTC
Details of what command/program/actions reproduce the crash
calling on console:
stack build 

- pkg version -v output (as an attachment)
1.13.2

- var/run/dmesg.boot output (as an attachment)
see attachment
Comment 6 pmueller@occsilva.de 2020-06-19 17:39:46 UTC
Hello,

I changed the pkg settings to "latest".
Then I updated the installed packages.

Now I have pkg 1.14.4

Then I uninstalled hs-stack and built it myself.

Took a while but it is now available.

But still the same problem.

This is what gdb shows when I load the core dump and show bt.

(gdb) bt
#0  0x0000000001a626a5 in ?? ()
#1  0x000000420060bec0 in ?? ()
#2  0x0000000003416340 in ?? ()
#3  0x000000000000000c in ?? ()
#4  0x000000420060be60 in ?? ()
#5  0x000000420060be70 in ?? ()
#6  0x00000000039e4ed0 in ?? ()
#7  0x0000000001a60713 in ?? ()
#8  0x0000000000000000 in ?? ()
(gdb)
Comment 7 pmueller@occsilva.de 2020-06-19 17:44:12 UTC
Hello,

I changed the pkg settings to "latest".
Then I updated the installed packages.

Now I have pkg 1.14.4

Then I uninstalled hs-stack and built it myself.

Took a while but it is now available.

But still the same problem.

This is what gdb shows when I load the core dump and show bt.

(gdb) bt
#0  0x0000000001a626a5 in ?? ()
#1  0x000000420060bec0 in ?? ()
#2  0x0000000003416340 in ?? ()
#3  0x000000000000000c in ?? ()
#4  0x000000420060be60 in ?? ()
#5  0x000000420060be70 in ?? ()
#6  0x00000000039e4ed0 in ?? ()
#7  0x0000000001a60713 in ?? ()
#8  0x0000000000000000 in ?? ()
(gdb)
Comment 8 Gleb Popov freebsd_committer 2020-06-21 08:08:14 UTC
Can you run `disas` in GDB prompt right after crash and find the instruction that causes the error?
Comment 9 pmueller@occsilva.de 2020-06-21 09:14:48 UTC
Is this what you asked for:

lldb shows:

lldb /usr/local/libexec/cabal/stack
(lldb) target create "/usr/local/libexec/cabal/stack"
Current executable set to '/usr/local/libexec/cabal/stack' (x86_64).
(lldb) r build
Process 78060 launching
Process 78060 launched: '/usr/local/libexec/cabal/stack' (x86_64)
Process 78060 stopped
* thread #3, name = 'stack', stop reason = signal SIGILL: privileged instruction
    frame #0: 0x0000000001a626a5 stack`cryptonite_aes_generic_encrypt_block + 277
stack`cryptonite_aes_generic_encrypt_block:
->  0x1a626a5 <+277>: pshufb %xmm8, %xmm7
    0x1a626ab <+283>: movdqa -0x1761764(%rip), %xmm9
    0x1a626b4 <+292>: pshufb %xmm9, %xmm6
    0x1a626ba <+298>: por    %xmm7, %xmm6
(lldb)


GDB shows:
gdb /usr/local/libexec/cabal/stack
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
(gdb) r build
Starting program: /usr/local/libexec/cabal/stack build
[New LWP 101655]
BFD: /lib/libc.so.7: invalid relocation type 37
BFD: BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail /usr/src/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/elf64-x86-64.c:276
[New Thread 80f2ea000 (LWP 101655/stack)]
[New Thread 80f2eaf00 (LWP 101530/stack)]

Program received signal SIGILL, Illegal instruction.
[Switching to Thread 80f2eaf00 (LWP 101530/stack)]
0x0000000001a626a5 in cryptonite_aes_generic_encrypt_block ()
(gdb)
Comment 10 Gleb Popov freebsd_committer 2020-06-21 09:23:18 UTC
(In reply to pmueller@occsilva.de from comment #9)
Great, this is useful!

Can you try building stack with this patch applied?

Index: devel/stack/Makefile
===================================================================
--- devel/stack/Makefile        (revision 539747)
+++ devel/stack/Makefile        (working copy)
@@ -4,6 +4,7 @@
 PORTNAME=      stack
 PORTVERSION=   2.3.1
 DISTVERSIONPREFIX=     v
+PORTREVISION=  1
 CATEGORIES=    devel haskell
 EXTRACT_ONLY=  ${DISTNAME}${EXTRACT_SUFX}
 
@@ -24,6 +25,7 @@
 
 USE_PERL5=     run
 
+CABAL_FLAGS=   -support_aesni
 USE_CABAL=     aeson-1.4.7.1_1 \
                annotated-wl-pprint-0.7.0_1 \
                ansi-terminal-0.10.3 \
Comment 11 pmueller@occsilva.de 2020-06-22 15:09:57 UTC
Now it works! 

Thanks for your help.

What is the solution? Have compiler settings produced assembler code that my CPU can't handle?
Comment 12 commit-hook freebsd_committer 2020-06-22 16:57:31 UTC
A commit references this bug:

Author: arrowd
Date: Mon Jun 22 16:56:59 UTC 2020
New revision: 539885
URL: https://svnweb.freebsd.org/changeset/ports/539885

Log:
  devel/stack: Disable AESNI when building cryptonite library.

  This Haskell library contains C code, which uses advanced instructions not present in older amd64 CPUs.

  PR:		247288
  Reported by:	pmueller@occsilva.de
  MFH:		2020Q2

Changes:
  head/devel/stack/Makefile