Subject: Re: {s,}brk removed from FreeBSD 11.x and later, arm64 architecture

From: [email-masked] (Ashish SHUKLA)
Date: Wed, 09 Nov 2016 09:59:12 +0530

On Tue, 8 Nov 2016 09:54:45 -0800, Paul Eggert <[email-masked]> said:
| Thanks for reporting that. Although I don't have easy access to that
| platform, I simulated the problem on FreeBSD 11 x86-64 and came up
| with the attached patch, which I installed into the Emacs master
| branch. Please give it a try if you can, and let me know either way. I
| doubt whether this patch will apply to Emacs 25 and have not
| investigated the details there.

Tried your diff on Emacs 25.1, it segfaulted:

,----[ emacs-25.1
| Dumping under the name emacs
| 82523 pure bytes used
| mv -f emacs bootstrap-emacs
| gmake -C ../lisp compile-first EMACS="../src/bootstrap-emacs"
| gmake[3]: Entering directory '/scratch/ashish/work/emacs-25.1/lisp'
| gmake[3]: Nothing to be done for 'compile-first'.
| gmake[3]: Leaving directory '/scratch/ashish/work/emacs-25.1/lisp'
| gmake -C ../admin/charsets cp51932.el
| gmake[3]: Entering directory '/scratch/ashish/work/emacs-25.1/admin/charsets'
| gmake[3]: Nothing to be done for 'cp51932.el'.
| gmake[3]: Leaving directory '/scratch/ashish/work/emacs-25.1/admin/charsets'
| gmake -C ../admin/charsets eucjp-ms.el
| gmake[3]: Entering directory '/scratch/ashish/work/emacs-25.1/admin/charsets'
| gmake[3]: Nothing to be done for 'eucjp-ms.el'.
| gmake[3]: Leaving directory '/scratch/ashish/work/emacs-25.1/admin/charsets'
| gmake -C ../admin/unidata all EMACS="../../src/bootstrap-emacs"
| gmake[3]: Entering directory '/scratch/ashish/work/emacs-25.1/admin/unidata'
| for f in `sed -n 's/^;; FILE: //p' < ../../lisp/international/charprop.el`; do \
|   [ -f ../../lisp/international/$f ] || exec gmake PHONY_EXTRAS=../../lisp/international/charprop.el ../../lisp/international/charprop.el; \
| done
| gmake[3]: Leaving directory '/scratch/ashish/work/emacs-25.1/admin/unidata'
| /bin/mkdir -p ../etc
| rm -f ../etc/DOC
| ../lib-src/make-docfile -d . \
|   dosfns.o msdos.o xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o fontset.o dbusbind.o cygw32.o nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macfont.o w32.o w32console.o w32fns.o w32heap.o w32inevt.o w32notify.o w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o w16select.o widget.o xfont.o ftfont.o xftfont.o ftxfont.o gtkutil.o xsettings.o xgselect.o termcap.o dispnew.o frame.o scroll.o xdisp.o menu.o  window.o charset.o coding.o category.o ccl.o character.o chartab.o bidi.o cm.o term.o terminal.o xfaces.o    emacs.o keyboard.o macros.o keymap.o sysdep.o buffer.o filelock.o insdel.o marker.o minibuf.o fileio.o dired.o cmds.o casetab.o casefiddle.o indent.o search.o regex.o undo.o alloc.o data.o doc.o editfns.o callint.o eval.o floatfns.o fns.o font.o print.o lread.o dynlib.o emacs-module.o syntax.o unexelf.o bytecode.o process.o gnutls.o callproc.o region-cache.o sound.o atimer.o doprnt.o intervals.o textprop.o composite.o xml.o kqueue.o  profiler.o decompress.o          > ../etc/DOC
| ../lib-src/make-docfile -a ../etc/DOC -d ../lisp \
|   loaddefs.el loadup.el abbrev.elc bindings.elc buff-menu.elc button.elc case-table.elc composite.elc cus-face.elc cus-start.elc custom.elc disp-table.elc dnd.elc dos-fns.elc dos-vars.elc dos-w32.elc dynamic-setting.elc electric.elc emacs-lisp/backquote.elc emacs-lisp/byte-run.elc emacs-lisp/cl-generic.elc emacs-lisp/cl-preloaded.elc emacs-lisp/eldoc.elc emacs-lisp/float-sup.elc emacs-lisp/lisp-mode.elc emacs-lisp/lisp.elc emacs-lisp/macroexp.elc emacs-lisp/map-ynp.elc emacs-lisp/nadvice.elc emacs-lisp/regexp-opt.elc emacs-lisp/syntax.elc emacs-lisp/tabulated-list.elc emacs-lisp/timer.elc env.elc epa-hook.elc facemenu.elc faces.elc files.elc font-core.elc font-lock.elc format.elc frame.elc fringe.elc help.elc image.elc indent.elc international/characters.elc international/cp51932.elc international/eucjp-ms.elc international/fontset.elc international/mule-cmds.elc international/mule-conf.elc international/mule.elc international/ucs-normalize.elc isearch.elc jit-lock.elc jka-cmpr-hook.elc language/burmese.elc language/cham.elc language/chinese.elc language/cyrillic.elc language/czech.elc language/english.elc language/ethiopic.elc language/european.elc language/georgian.elc language/greek.elc language/hebrew.elc language/indian.elc language/japanese.elc language/khmer.elc language/korean.elc language/lao.elc language/misc-lang.elc language/romanian.elc language/sinhala.elclanguage/slovak.elc language/tai-viet.elc language/thai.elc language/tibetan.elc language/utf-8-lang.elc language/vietnamese.elc ls-lisp.elc menu-bar.elc minibuffer.elc mouse.elc mwheel.elc newcomment.elc progmodes/elisp-mode.elc progmodes/prog-mode.elc register.elc replace.elc rfn-eshadow.elc scroll-bar.elc select.elc simple.elc startup.elc subr.elc term/common-win.elc term/internal.elc term/ns-win.elc term/pc-win.elc term/tty-colors.elc term/w32-win.elc term/x-win.elc textmodes/fill.elc textmodes/page.elc textmodes/paragraphs.elc textmodes/text-mode.elc tool-bar.elc tooltip.elc uniquify.elc vc/ediff-hook.elc vc/vc-hooks.elc version.elc w32-fns.elc w32-vars.elc widget.elc window.elc x-dnd.elc
| gmake -C ../leim leim-list.el EMACS="../src/bootstrap-emacs"
| gmake[3]: Entering directory '/scratch/ashish/work/emacs-25.1/leim'
| rm -f ../lisp/leim/leim-list.el
| EMACSLOADPATH= '../src/bootstrap-emacs' -batch --no-site-file --no-site-lisp -l international/quail \
|   --eval "(update-leim-list-file (unmsys--file-name \"./../lisp/leim\"))"
| Fatal error 11: Segmentation faultgmake[3]: *** [Makefile:134: ../lisp/leim/leim-list.el] Segmentation fault (core dumped)
| gmake[3]: Leaving directory '/scratch/ashish/work/emacs-25.1/leim'
| gmake[2]: *** [Makefile:490: ../lisp/leim/leim-list.el] Error 2
| gmake[2]: Leaving directory '/scratch/ashish/work/emacs-25.1/src'
| gmake[1]: *** [Makefile:398: src] Error 2
| gmake[1]: Leaving directory '/scratch/ashish/work/emacs-25.1'
| *** Error code 1
| 
| % lldb src/bootstrap-emacs -c leim/bootstrap-emacs.core                                                                       
| 
| (lldb) target create "src/bootstrap-emacs" --core "leim/bootstrap-emacs.core"
| Core file '/scratch/ashish/work/emacs-25.1-old/leim/bootstrap-emacs.core' (aarch64) was loaded.
| (lldb) bt all
| bootstrap-emacs was compiled with optimization - stepping may behave oddly; variables may not be available.
| * thread #1: tid = 101155, 0x0000000000513450 bootstrap-emacs`oblookup [inlined] AREF + 4 at lisp.h:1526, name = 'bootstrap-emacs', stop reason = signal SIGSEGV
|   * frame #0: 0x0000000000513450 bootstrap-emacs`oblookup [inlined] AREF + 4 at lisp.h:1526 [opt]
|     frame #1: 0x000000000051344c bootstrap-emacs`oblookup(obarray=<unavailable>, ptr="", size=14, size_byte=14) + 120 at lread.c:3961 [opt]
|     frame #2: 0x000000000051330c bootstrap-emacs`intern_1(str="", len=14) + 96 at lread.c:3779 [opt]
|     frame #3: 0x00000000004bbdec bootstrap-emacs`Fdo_auto_save [inlined] intern(str=<unavailable>) + 208 at lisp.h:3836 [opt]
|     frame #4: 0x00000000004bbde8 bootstrap-emacs`Fdo_auto_save(no_message=<unavailable>, current_only=0) + 204 at fileio.c:5514 [opt]
|     frame #5: 0x0000000000487230 bootstrap-emacs`shut_down_emacs(sig=11, stuff=0) + 216 at emacs.c:2000 [opt]
|     frame #6: 0x0000000000487060 bootstrap-emacs`terminate_due_to_signal(sig=11, backtrace_limit=40) + 112 at emacs.c:365 [opt]
|     frame #7: 0x00000000004a11c8 bootstrap-emacs`deliver_fatal_thread_signal [inlined] handle_fatal_signal(sig=11) + 128 at sysdep.c:1601 [opt]
|     frame #8: 0x00000000004a11bc bootstrap-emacs`deliver_fatal_thread_signal [inlined] deliver_thread_signal + 100 at sysdep.c:1575 [opt]
|     frame #9: 0x00000000004a1158 bootstrap-emacs`deliver_fatal_thread_signal(sig=<unavailable>) + 16 at sysdep.c:1613 [opt]
|     frame #10: 0x00000000004a27e4 bootstrap-emacs`handle_sigsegv(sig=<unavailable>, siginfo=<unavailable>, arg=<unavailable>) + 152 at sysdep.c:1695 [opt]
|     frame #11: 0x000000004065abb0 libthr.so.3`handle_signal(actp=0x00000000008c9a60, sig=11, info=0x00000000008c9ad0, ucp=0x00000000008c9b20) + 256 at thr_sig.c:244 [opt]
|     frame #12: 0x000000004065a318 libthr.so.3`thr_sighandler(sig=11, info=0x00000000008c9ad0, _ucp=0x00000000008c9b20) + 248 at thr_sig.c:189 [opt]
|     frame #13: 0x0000fffffffff000
|     frame #14: 0x0000000000405560 bootstrap-emacs`__start + 360
|     frame #15: 0x0000000040583630 ld-elf.so.1 at rtld_start.S:41
`----

On Emacs master branch, where diff is already present, it segfaults:

,----[ emacs master branch
| Loading /scratch/ashish/work/emacs-master/lisp/mouse.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/select.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/emacs-lisp/timer.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/isearch.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/rfn-eshadow.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/menu-bar.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/emacs-lisp/lisp.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/textmodes/page.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/register.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/textmodes/paragraphs.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/progmodes/prog-mode.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/emacs-lisp/lisp-mode.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/progmodes/elisp-mode.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/textmodes/text-mode.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/textmodes/fill.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/newcomment.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/replace.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/emacs-lisp/tabulated-list.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/buff-menu.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/emacs-lisp/float-sup.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/vc/vc-hooks.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/vc/ediff-hook.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/uniquify.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/electric.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/emacs-lisp/eldoc.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/cus-start.el (source)...
| Loading /scratch/ashish/work/emacs-master/lisp/tooltip.el (source)...
| Finding pointers to doc strings...
| Finding pointers to doc strings...done
| Dumping under the name emacs
| 82347 pure bytes used
| mv -f emacs bootstrap-emacs
| gmake -C ../lisp compile-first EMACS="../src/bootstrap-emacs"
| gmake[3]: Entering directory '/scratch/ashish/work/emacs-master/lisp'
| EMACSLOADPATH= '../src/bootstrap-emacs' -batch --no-site-file --no-site-lisp --eval '(setq load-prefer-newer t)'  -f batch-byte-compile emacs-lisp/macroexp.el
| Fatal error 11: Segmentation faultgmake[3]: *** [Makefile:282: emacs-lisp/macroexp.elc] Segmentation fault (core dumped)
| gmake[3]: Leaving directory '/scratch/ashish/work/emacs-master/lisp'
| gmake[2]: *** [Makefile:757: bootstrap-emacs] Error 2
| gmake[2]: Leaving directory '/scratch/ashish/work/emacs-master/src'
| gmake[1]: *** [Makefile:398: src] Error 2
| gmake[1]: Leaving directory '/scratch/ashish/work/emacs-master'
| 
| % lldb ./src/bootstrap-emacs -c ./lisp/bootstrap-emacs.core
| (lldb) target create "./src/bootstrap-emacs" --core "./lisp/bootstrap-emacs.core"
| Core file '/scratch/ashish/work/emacs-master/./lisp/bootstrap-emacs.core' (aarch64) was loaded.
| (lldb) bt all
| bootstrap-emacs was compiled with optimization - stepping may behave oddly; variables may not be available.
| * thread #1: tid = 101215, 0x0000000000514ea0 bootstrap-emacs`oblookup [inlined] AREF + 4 at lisp.h:1529, name = 'bootstrap-emacs', stop reason = signal SIGSEGV
|   * frame #0: 0x0000000000514ea0 bootstrap-emacs`oblookup [inlined] AREF + 4 at lisp.h:1529 [opt]
|     frame #1: 0x0000000000514e9c bootstrap-emacs`oblookup(obarray=<unavailable>, ptr="", size=14, size_byte=14) + 120 at lread.c:4044 [opt]
|     frame #2: 0x0000000000514d5c bootstrap-emacs`intern_1(str="", len=14) + 96 at lread.c:3862 [opt]
|     frame #3: 0x00000000004bd77c bootstrap-emacs`Fdo_auto_save [inlined] intern(str=<unavailable>) + 208 at lisp.h:3837 [opt]
|     frame #4: 0x00000000004bd778 bootstrap-emacs`Fdo_auto_save(no_message=<unavailable>, current_only=0) + 204 at fileio.c:5538 [opt]
|     frame #5: 0x0000000000488ab4 bootstrap-emacs`shut_down_emacs(sig=11, stuff=0) + 216 at emacs.c:2034 [opt]
|     frame #6: 0x00000000004888e4 bootstrap-emacs`terminate_due_to_signal(sig=11, backtrace_limit=40) + 128 at emacs.c:375 [opt]
|     frame #7: 0x00000000004a334c bootstrap-emacs`deliver_fatal_thread_signal [inlined] handle_fatal_signal(sig=11) + 128 at sysdep.c:1680 [opt]
|     frame #8: 0x00000000004a3340 bootstrap-emacs`deliver_fatal_thread_signal [inlined] deliver_thread_signal + 100 at sysdep.c:1654 [opt]
|     frame #9: 0x00000000004a32dc bootstrap-emacs`deliver_fatal_thread_signal(sig=<unavailable>) + 16 at sysdep.c:1692 [opt]
|     frame #10: 0x00000000004a496c bootstrap-emacs`handle_sigsegv(sig=<unavailable>, siginfo=<unavailable>, arg=<unavailable>) + 168 at sysdep.c:1777 [opt]
|     frame #11: 0x000000004065cbb0 libthr.so.3`handle_signal(actp=0x00000000008f4710, sig=11, info=0x00000000008f4780, ucp=0x00000000008f47d0) + 256 at thr_sig.c:244 [opt]
|     frame #12: 0x000000004065c318 libthr.so.3`thr_sighandler(sig=11, info=0x00000000008f4780, _ucp=0x00000000008f47d0) + 248 at thr_sig.c:189 [opt]
|     frame #13: 0x0000fffffffff000
|     frame #14: 0x00000000004dfa0c bootstrap-emacs`init_alloc [inlined] make_float(float_value=0) + 64 at alloc.c:2649 [opt]
|     frame #15: 0x00000000004df9cc bootstrap-emacs`init_alloc at alloc.c:7304 [opt]
|     frame #16: 0x000000000048929c bootstrap-emacs`main(argc=0, argv=<unavailable>) + 1944 at emacs.c:1214 [opt]
|     frame #17: 0x00000000004054c0 bootstrap-emacs`__start + 360
|     frame #18: 0x0000000040585630 ld-elf.so.1 at rtld_start.S:41
`----

Please let me know if you need more information.

Thanks!
-- 
Ashish SHUKLA

“Living on Earth may be expensive, but it includes an annual free trip
around the Sun.”

Sent from my Emacs