使用erc时spacemacs总是崩溃

相关信息:

  1. 使用的是spacemacs develop分支

  2. emacs-26.1 和 emacs-25 都试过,都会崩溃

  3. 不开erc时使用一切正常

  4. 使用erc连接我自己的znc server,开始一切正常,能收发信息,用一会儿emacs就会崩溃

  5. 使用gentoo操作系统,Emacs的use flag如下

(X acl athena gif imagemagick inotify jpeg kerberos libxml2 png ssl svg threads tiff xft xpm zlib -Xaw3d -alsa -aqua -cairo -dbus -dynamic-loading -games -gconf -gfile -gpm -gsettings -gtk -gtk3 -gzip-el -lcms -livecd -m17n-lib -mailutils -motif -selinux -sound -source -systemd -toolkit-scroll-bars -wide-int -xwidgets)

  1. gcc版本是6.4.0-r1

  2. 崩溃后终端信息如下:

     Fatal error 4: Illegal instruction 
     Backtrace: 
     emacs[0x4fdbcc] 
     emacs[0x4e3757] 
     emacs[0x4fc08e] 
     emacs[0x4fc399] 
     emacs[0x4fc449] 
     /lib64/libpthread.so.0(+0x13f90)[0x7fcfdd2bff90] 
     /usr/lib64/libnettle.so.6(_nettle_aes_encrypt+0x23)[0x7fcfd95643d3] 
     [1] 55882 illegal hardware instruction emacs -nw

需要编译个debug版本,然后用gdb启动,这样才能得到又有信息

Gentoo 的 make.conf 贴上来,emerge --info 输出也贴上,顺带把 CPU 型号报一下。很明显你用了 CPU 不支持的指令集,所以得怀疑你是不是乱开了什么负优化

1 个赞

不错的建议, gentoo没有提供emacs的debug编译选项, 我去下载一份emacs源码试试

感谢提点! 我使用了双路E5-2696 v4 CPU, 按产品线属于broadwell, 但gentoo官方的安全CFLAGS手册中没有提到E5 v4系列, 我之前设置CFLAGS="-march=broadwell" 倒也没出什么问题. emacs出现问题后, 我把CFLAGS改回-march=native, 并重新编译了emacs, nettle和glibc, 但问题仍然存在.

以下是make.conf

CFLAGS="-march=native -O3 -pipe"
CXXFLAGS="${CFLAGS}"
MAKEOPTS="-j89"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
# These are the USE and USE_EXPAND flags that were used for
# buidling in addition to what is provided by the profile.
USE="X abi_x86_64"
CPU_FLAGS_X86="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3 sse4 sse4a"
PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
PYTHON_TARGETS="python2_7 python3_5 python3_6"
#iiPYTHON_TARGETS="python3_5"
GENTOO_MIRRORS="http://mirrors.163.com/gentoo/"
source /var/lib/layman/make.conf
PORTDIR_OVERLAY=${PORTDIR_OVERLAY}

APACHE2_MPMS="event"
NGINX_MODULES_HTTP="cache_purge gzip rewrite proxy memcached fastcgi map dav dav_ext auth_basic auth_pam auth_request"
NGINX_MODULES_STREAM="upstream"

PHP_TARGETS="php5-6 php7-1"
GRUB_PLATFORMS="efi-64"
LINGUAS="en zh_CN"
L10N="zh"

以下是emerge --info

Portage 2.3.24 (python 3.5.4-final-0, default/linux/amd64/17.0/no-multilib, gcc-6.4.0, glibc-2.25-r11, 4.9.6-gentoo-r1-Enigma x86_64)
=================================================================
System uname: Linux[email protected]_2.20GHz-with-gentoo-2.3
KiB Mem:   131903576 total, 103661872 free
KiB Swap:  134217724 total, 134217724 free
Timestamp of repository gentoo: Wed, 30 May 2018 02:00:01 +0000
Head commit of repository gentoo: 826b0d45dfea7e855ce336f4592acd9a1c9149ac
sh bash 4.3_p48-r1
ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1
app-shells/bash:          4.3_p48-r1::gentoo
dev-java/java-config:     2.2.0-r4::gentoo
dev-lang/perl:            5.24.1-r1::gentoo
dev-lang/python:          2.7.12::gentoo, 3.4.5::gentoo, 3.5.4::gentoo, 3.6.5::gentoo
dev-util/cmake:           3.9.6::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.3::gentoo
sys-apps/openrc:          0.32.1::gentoo
sys-apps/sandbox:         2.10-r3::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69::gentoo
sys-devel/automake:       1.9.6-r4::gentoo, 1.14.1::gentoo, 1.15.1-r2::gentoo
sys-devel/binutils:       2.25.1-r1::gentoo, 2.28.1::gentoo, 2.29.1-r1::gentoo
sys-devel/gcc:            4.8.5::gentoo, 4.9.4::gentoo, 5.4.0-r3::gentoo, 6.4.0-r1::gentoo, 7.3.0-r1::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r2::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 4.4::gentoo (virtual/os-headers)
sys-libs/glibc:           2.25-r11::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-metamanifest: no
    sync-rsync-extra-opts: 

archenroot
    location: /var/lib/layman/archenroot
    masters: gentoo
    priority: 50

betagarden
    location: /var/lib/layman/betagarden
    masters: gentoo
    priority: 50

cg
    location: /var/lib/layman/cg
    masters: gentoo
    priority: 50

dotnet
    location: /var/lib/layman/dotnet
    masters: gentoo
    priority: 50

jm-overlay
    location: /var/lib/layman/jm-overlay
    masters: dotnet gentoo
    priority: 50

pigfoot
    location: /var/lib/layman/pigfoot
    masters: gentoo
    priority: 50

proaudio
    location: /var/lib/layman/proaudio
    masters: gentoo
    priority: 50

seeds
    location: /var/lib/layman/seeds
    masters: gentoo
    priority: 50

ssnb
    location: /var/lib/layman/ssnb
    masters: gentoo
    priority: 50

ultrabug
    location: /var/lib/layman/ultrabug
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* [email protected]"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O3 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /usr/share/maven-bin-3.0/conf /usr/share/maven-bin-3.3/conf"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.6/ext-active/ /etc/php/apache2-php7.1/ext-active/ /etc/php/cgi-php5.6/ext-active/ /etc/php/cgi-php7.1/ext-active/ /etc/php/cli-php5.6/ext-active/ /etc/php/cli-php7.1/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O3 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://mirrors.163.com/gentoo/"
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en zh_CN"
MAKEOPTS="-j89"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X acl amd64 berkdb bzip2 cli crypt cxx dri fortran gdbm iconv ipv6 modules ncurses nls nptl openmp pam pcre readline seccomp ssl tcpd unicode xattr zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" APACHE2_MPMS="event" CALLIGRA_FEATURES="karbon plan sheets stage words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3 sse4 sse4a" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" L10N="zh" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" NGINX_MODULES_HTTP="cache_purge gzip rewrite proxy memcached fastcgi map dav dav_ext auth_basic auth_pam auth_request" NGINX_MODULES_STREAM="upstream" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-1" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_5" PYTHON_TARGETS="python2_7 python3_5 python3_6" RUBY_TARGETS="ruby23" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

我注意到make.conf中设置的CPU_FLAGS_X86, 似乎和/proc/cpuinfo 的flags不尽相同. 然后去google了一下, 发现gentoo官方的wiki中有关于CPU_FLAGS_X86的设置指南, 需要用到一个叫cpuid2cpuflags的工具. 我当初设置这个变量时没有按这个流程来. 现在使用cpuid2cpuflags得到的结果是 avx avx2 f16c fma3 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3 和之前的结果相比, 少了aes和sse4a, 多了pclmul. 不知道原先的bug是否因此而起? 我用新的CPU_FLAGS_X86重新编译了一遍, 现在还在测试中.

1 个赞

之前要 make.conf 的時候就有預感。

重新编译的時候保險起見可以考慮用

emerge -1e emacs

这樣所有 Emacs 相關的都会重新编译。

erc的问题已经解决了, 目前一切正常. 看来确实是CFLAGS设置的问题. 另外, 阁下关于重新编译的建议也非常正确, 如果不加限制可能会使整个系统全部重新编译, 这对gentoo这样的系统来说代价不小. 再次感谢指教!

Gentoo 编译器相关的问题越要解决越好。稳定下来以后反而基本不用操心了,虽然是滚动更新也没有特别频繁,两周一次就够了。另外推荐花点功夫换上 BTRFS 或者 ZFS,有全盘快照以后就算不小心把系统搞坏了修起来也很快。