Subject: bug#48342: native-comp emacs gets into an infinite loop at startup if no .el files are available

From: Dima Kogan <[email-masked]>
Date: Tue, 11 May 2021 10:29:20 -0700

Eli Zaretskii <[email-masked]> writes:

> Any idea how come display-warning calls itself?

I'm here:

  https://github.com/emacs-mirror/emacs/commit/bb8b8d

A single recursive cycle in the C backtrace looks like this:

  #21 0x000055555573b282 in maybe_swap_for_eln (no_native=no_native@entry=false, filename=filename@entry=0x7fffffebd780, fd=fd@entry=0x7fffffebd77c, mtime=...) at lread.c:1713
  #22 0x000055555573ba5d in openp (path=0x555555d75e63, str=0x7fffeefb3a1c, suffixes=<optimized out>, storeptr=0x7fffffebd958, predicate=0x0, newer=false, no_native=false) at ../lib/stat-time.h:149
  #23 0x000055555573ed05 in Fload (file=0x7fffeefb3a1c, noerror=0x0, nomessage=0x30, nosuffix=0x0, must_suffix=<optimized out>) at lisp.h:1002
  #24 0x000055555573faef in save_match_data_load (file=0x7fffeefb3a1c, noerror=noerror@entry=0x0, nomessage=nomessage@entry=0x30, nosuffix=nosuffix@entry=0x0, must_suffix=must_suffix@entry=0x30) at lread.c:1616
  #25 0x0000555555713d57 in Fautoload_do_load (fundef=0x7fffef14ed9b, funname=0x2aaa99569808, macro_only=0x0) at eval.c:2308
  #26 0x0000555555714040 in Ffuncall (nargs=3, args=0x7fffffebdbd0) at lisp.h:1002
  #27 0x0000555555714211 in call2 (fn=<optimized out>, arg1=arg1@entry=0x4650, arg2=arg2@entry=0x555555f11bf4) at eval.c:2903
  #28 0x000055555573b282 in maybe_swap_for_eln (no_native=no_native@entry=false, filename=filename@entry=0x7fffffebdd80, fd=fd@entry=0x7fffffebdd7c, mtime=...) at lread.c:1713

The maybe_swap_for_el() call in Frame #28 checks for the sources, sees
that the file on disk doesn't exist, and throws the warning as expected:

Code:
  call2 (intern_c_string ("display-warning")
Full context:
  https://github.com/emacs-mirror/emacs/blob/bb8b8d717f91a85ca41de9e82246e6975e1ed719/src/lread.c#L1713

Frame #26 is the (display-warning ...)

Frame #25 is (autoload-do-load ... 'display-warning)

Frame #23 is (load "warnings" ...)

The backtrace isn't right about the line number in frame #22, but that
function is in lread.c. It's trying to compile "warnings.el".

> Note that if you will be distributing the *.eln files, I think the GPL
> requires you to make the *.el files available. In fact, this is so
> even with the *.elc files. So I'm not sure I understand how you could
> distribute only the *.elc files until now: isn't that contrary to GPL?

The .el files are available, but the user doesn't have to install them.
Just like the .c sources are available, but the user can install just
the pre-built binaries if they want to.