Bug 217567

Summary: editors/emacs temacs dumps core during build on base/head amd64 using system compiler clang 4.0.1
Product: Ports & Packages Reporter: Trond Endrestøl <Trond.Endrestol>
Component: Individual Port(s)Assignee: Ashish SHUKLA <ashish>
Status: Closed Overcome By Events    
Severity: Affects Many People CC: jbeich, kib
Priority: --- Flags: bugzilla: maintainer-feedback? (ashish)
Version: Latest   
Hardware: amd64   
OS: Any   
Attachments:
Description Flags
Complete ktrace dump from running temacs manually
none
Complete none

Description Trond Endrestøl 2017-03-05 16:45:20 UTC
The following happens when building editors/emacs (and child ports such as editors/emacs-nox11) on base/head amd64 after r314564, clang 4.0.0 as the system compiler:

gmake[4]: Entering directory '/usr/ports/workdirs/usr/ports/editors/emacs/work/emacs-25.1/lisp'
for file in . ./calc ./calendar ./emacs-lisp ./emulation ./erc ./eshell ./gnus ./international ./language ./mail ./mh-e ./net ./nxml ./obsolete ./org ./play ./progmodes ./term ./textmodes ./url ./vc; do \
   ./../build-aux/update-subdirs $file; \
done;
gmake[4]: Leaving directory '/usr/ports/workdirs/usr/ports/editors/emacs/work/emacs-25.1/lisp'
./temacs --batch --load loadup bootstrap
Fatal error 'Can't allocate initial thread' at line 338 in file /usr/src/lib/libthr/thread/thr_init.c (errno = 22)
gmake[3]: *** [Makefile:737: bootstrap-emacs] Abort trap (core dumped)
gmake[3]: Leaving directory '/usr/ports/workdirs/usr/ports/editors/emacs/work/emacs-25.1/src'
gmake[2]: *** [Makefile:398: src] Error 2
gmake[2]: Leaving directory '/usr/ports/workdirs/usr/ports/editors/emacs/work/emacs-25.1'

The port builds successfully with clang 3.9.1, i.e. pre-r314564.
Comment 2 Trond Endrestøl 2017-06-27 18:00:44 UTC
(In reply to Jan Beich from comment #1)
It builds fine om base/head r320406.
Most likely the attempts at fixing Stack Clash interfered for a while.
Comment 3 Trond Endrestøl 2017-06-27 18:01:15 UTC
Builds again on base/head r320406.
Comment 4 Trond Endrestøl 2017-07-19 09:30:36 UTC
A new but similar bug has appeared since last time.

Now I'm running base/head r321183 amd64, and temacs still fails to run during build of editors/emacs.

$ ./temacs
Fatal error 'Can't allocate initial thread' at line 337 in file /usr/src/lib/libthr/thread/thr_init.c (errno = 22)

Running ktrace reveals a failed call to break(2):

  6355 temacs   CALL  break(0x409e11)
  6355 temacs   RET   break -1 errno 22 Invalid argument

$ make showconfig
===> The following configuration options are available for emacs25-25.2_2,3:
     ACL=off: Access control list support
     CANNA=off: Japanese input support
     DBUS=off: D-Bus IPC system support
     GNUTLS=on: SSL/TLS support via GnuTLS
     LLDB=on: LLDB support for GUD
     MODULES=on: Dynamic modules support
     SOURCES=on: Install sources
     X11=on: X window system support
     XML=on: XML format or parser support
====> Graphics support (each implies X11)
     CAIRO=off: Experimental Cairo library support     (implies PNG, XFT)
     GIF=on: GIF image format support
     JPEG=on: JPEG image format support
     MAGICK=on: ImageMagick image processing support
     PNG=on: PNG image format support
     SVG=on: Scalable vector graphics support       (implies PNG)
     TIFF=on: TIFF image format support
     XPM=on: XPM pixmap image format support
====> Other X11-dependent (each implies X11)
     GCONF=off: GConf configuration backend support
     GSETTINGS=off: GSettings API for application settings
     M17N=on: M17N for text-shaping                  (implies XFT)
     OTF=on: Opentype fonts                         (implies XFT)
     SCROLLBARS=on: Toolkit scroll-bars
     XFT=on: Xft font library support
     XIM=on: X Input Method
     XWIDGETS=off: GTK widgets in Emacs buffers           (requires GTK3)
====> File notification support: you can only select none or one of them
     GFILE=off: File notification via gfile
     KQUEUE=on: File notification via kqueue
====> Sound (audio) support: you can only select none or one of them
     ALSA=off: ALSA audio architecture support
     OSS=off: Open Sound System support
====> X11 toolkit (each implies X11): you can only select none or one of them
     GTK2=off: GTK+ 2 GUI toolkit support
     GTK3=on: GTK+ 3 GUI toolkit support
     MOTIF=off: Motif widget library support
     XAW=off: Athena widgets
     XAW3D=off: Athena3D widgets
===> Use 'make config' to modify these settings

Complete ktrace dump and typescript from running make build will be attached shortly.
Comment 5 Trond Endrestøl 2017-07-19 09:31:44 UTC
Created attachment 184493 [details]
Complete ktrace dump from running temacs manually
Comment 6 Trond Endrestøl 2017-07-19 09:32:08 UTC
Created attachment 184494 [details]
Complete
Comment 7 Trond Endrestøl 2017-07-19 09:34:01 UTC
Comment on attachment 184494 [details]
Complete

Complete typescript from building editors/emacs. (Firefox is sure acting up, be it the backspace key or upwards on the scroll wheel on the mouse.)
Comment 8 Konstantin Belousov freebsd_committer freebsd_triage 2017-07-19 11:12:49 UTC
EINVAL from break(2) means that the supplied address is less than the end of the data segment.  Why break(2) was called there at all, and why it was passed the invalid argument, is the question to the application.

Above were the facts that I see from the backtrace, now I am stating something that is a speculation, but based on my experience with debugging enough usermode code.  I suspect that the program override the malloc(3) and the override is buggy, using obsolete break(2) interface.  You need to check why it tries to do that and why it works otherwise.

Why do you think that this is the same problem as the initial report, I do not know.
Comment 9 Trond Endrestøl 2017-07-22 11:11:35 UTC
(In reply to Konstantin Belousov from comment #8)
The similar error messages led me astray.
Anyway, editors/emacs and editors/emacs-nox11 works again at build and run time on base/head r321366 and ports/head r446377.
Comment 10 Trond Endrestøl 2017-07-22 11:12:21 UTC
Closed.