Subject: 28.1; Resource exhaustion with emacs 28's native compilation; need "-Q" for trampoline
From: Hin-Tak Leung <[email-masked]>
To: [email-masked]
Date: Mon, 19 Dec 2022 21:59:26 +0000 (UTC)
List-Id: <debbugs-submit.debbugs.gnu.org>

--text follows this line--

Basically this is about resource exhaustion with emacs 28's native
compilation, leading to crash if not caught. There is a missing "-Q" for
building "emacs-int-comp-subr--trampoline..*...el".

More details at:

https://bugzilla.redhat.com/show_bug.cgi?id=2109745
Bug 2109745 - emacs-ess spawn multiple processes with ... --batch -l /tmp/emacs-async-comp-ess-custom-*.el

and at

https://github.com/emacs-ess/ESS/issues/1222
Resource exhaustion with emacs 28's native compilation.

What happens seems to be this: emacs-ess have about 50+ files, which
would be natively compiled on fedora's recent native-compile-enabled
emacs.

On fedora, they also auto-load emacs-ess mode via site-lisp.

Now,
"/tmp/emacs-int-comp-subr--trampoline-64656c6574652d63686172_delete_char_0-*.el"
seems to be some kind of stub which needs to be natively compiled as a
prerequisite for any native compilation at all, and it needs to be done
once ever, and it writes to
~/.emacs.d/eln-cache/28.1-b1f2d84a/subr--trampoline-64656c6574652d63686172_delete_char_0.eln
, and do it exactly once.

However, currently, emacs 28 is doing this via:

"/usr/bin/emacs --batch -l /tmp/emacs-int-comp-subr--trampoline..."

missing a "-Q", and should be:

"/usr/bin/emacs -Q --batch -l /tmp/emacs-int-comp-subr--trampoline..."

The consequence of the missing "-Q" is that, this commands also loads
emacs-ess, and which requires native compilation, which launches more
copies of the process of "emacs ... --batch -l
/tmp/emacs-int-comp-subr--trampoline...".

We soon have hundred of copies of emacs running, and thousands, and leading to resource
exhaustion and eventual crash.

I don't know how that trampoline file is generated, and what is its exact purpose, but it seems to be generic (not specific to emacs-ess) , and that it
should be compiled with a missing "-Q", instead of running emacs --batch plain.

In GNU Emacs 28.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6)
 of 2022-07-15 built on buildhw-x86-02.iad2.fedoraproject.org
Windowing system distributor 'The X.Org Foundation', version 11.0.12014000
System Description: Fedora Linux 36 (Workstation Edition)

Configured using:
 'configure --build=x86_64-redhat-linux-gnu
 --host=x86_64-redhat-linux-gnu --program-prefix=
 --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
 --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
 --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
 --libexecdir=/usr/libexec --localstatedir=/var
 --sharedstatedir=/var/lib --mandir=/usr/share/man
 --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
 --with-rsvg --with-tiff --with-xpm --with-x-toolkit=gtk3 --with-gpm=no
 --with-xwidgets --with-modules --with-harfbuzz --with-cairo --with-json
 --with-native-compilation build_alias=x86_64-redhat-linux-gnu
 host_alias=x86_64-redhat-linux-gnu CC=gcc 'CFLAGS=-DMAIL_USE_LOCKF -O2
 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches
 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
 -Wp,-D_GLIBCXX_ASSERTIONS
 -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
 LDFLAGS=-Wl,-z,relro
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XDBE XIM XPM XWIDGETS GTK3 ZLIB

Important settings:
  value of $LC_MONETARY: en_GB.utf8
  value of $LC_NUMERIC: en_GB.utf8
  value of $LC_TIME: en_GB.utf8
  value of $LANG: en_GB.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/usr/share/emacs/site-lisp/lilypond-init hides /usr/share/emacs/site-lisp/site-start.d/lilypond-init

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils finder-inf package url-handlers
ess-site ess-toolbar ess-mouse mouseme browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
url-util url-parse auth-source eieio eieio-core eieio-loaddefs
password-cache url-vars mailcap ess-swv ess-noweb
ess-noweb-font-lock-mode ess-jags-d ess-bugs-l essd-els ess-xls-d
ess-vst-d ess-stata-mode ess-stata-lang cc-vars cc-defs make-regexp
ess-sp6w-d ess-sp5-d ess-sp4-d ess-sas-d ess-sas-l ess-sas-a ess-s4-d
ess-s3-d ess-omg-d ess-omg-l ess-arc-d ess-lsp-l ess-sp6-d ess-dde
ess-sp3-d ess-julia julia-mode cl ess-r-mode ess-r-flymake flymake-proc
flymake thingatpt ess-r-xref xref project ess-trns ess-r-package shell
pcomplete ess-r-syntax ess-r-completion ess-roxy ess-rd essddr noutline
outline easy-mmode hideshow ess-s-lang ess-help info ess-mode ess
ess-noweb-mode ess-inf ess-tracebug comp comp-cstr warnings rx cl-seq
cl-extra help-mode advice format-spec ess-generics compile
text-property-search ess-utils ido ess-custom executable comint
ansi-color ring clang-rename clang-include-fixer let-alist json subr-x
map seq byte-opt bytecomp byte-compile cconv clang-format cl-macs gv xml
cl-loaddefs cl-lib iso-transl tooltip eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads xwidget-internal dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 179768 7459)
 (symbols 48 16053 0)
 (strings 32 56305 2843)
 (string-bytes 1 1932240)
 (vectors 16 28343)
 (vector-slots 8 521371 19414)
 (floats 8 78 41)
 (intervals 56 332 0)
 (buffers 992 13))