Subject: bug#51689: emacs

From: Eli Zaretskii <[email-masked]>
Date: Sat, 20 Nov 2021 11:36:16 +0200

> Date: Fri, 19 Nov 2021 23:18:04 +0100
> From: Han Boetes <[email-masked]>
> Cc: [email-masked]
> 
> Another thing I noticed: if there is a valid ~/.config/emacs/init.el,
> emacs -nw -Q works fine. If I mv ~/.config/emacs{,.bak} I see the
> problem. I don't have a /etc/emacs folder either, so maybe that helps
> you in reproducing the issue?

Not really: too many unknowns here.

> And after
> 
>     (gdb) run -Q -nw
> 
> I get: 
> 
>     Breakpoint 3, 0x00000d95326ee646 in Fsignal ()
>     No symbol "error_symbol" in current context.

Your build lacks debugging symbols, sigh.

Anyway. I think I'm beginning to understand what's going on here.

Andrea, I need your help here.

Here's what I think happens: At startup, we call
tramp-register-archive-file-name-handler, because tramp-archive.el
does this:

  ;;;###autoload
  (progn (defun tramp-register-archive-file-name-handler ()
    "Add archive file name handler to `file-name-handler-alist'."
    (when tramp-archive-enabled
      (add-to-list 'file-name-handler-alist
		   (cons (tramp-archive-autoload-file-name-regexp)
			 #'tramp-archive-autoload-file-name-handler))
      (put #'tramp-archive-autoload-file-name-handler 'safe-magic t))))

  ;;;###autoload
  (progn
    (add-hook 'after-init-hook #'tramp-register-archive-file-name-handler)
    (add-hook
     'tramp-archive-unload-hook
     (lambda ()
       (remove-hook
	'after-init-hook #'tramp-register-archive-file-name-handler))))

So we call tramp-register-archive-file-name-handler, which invokes
tramp-archive-autoload-file-name-regexp, which does:

  ;; The definition of `tramp-archive-file-name-regexp' contains calls
  ;; to `regexp-opt', which cannot be autoloaded while loading
  ;; loaddefs.el.  So we use a macro, which is evaluated only when needed.
  ;;;###autoload
  (progn (defmacro tramp-archive-autoload-file-name-regexp ()
    "Regular expression matching archive file names."
    '(concat
      "\\`" "\\(" ".+" "\\."
	;; Default suffixes ...
	(regexp-opt tramp-archive-suffixes)
	;; ... with compression.
	"\\(?:" "\\." (regexp-opt tramp-archive-compression-suffixes) "\\)*"
      "\\)" ;; \1
      "\\(" "/" ".*" "\\)" "\\'"))) ;; \2

So this calls regexp-opt, which is an autoloaded function, so it loads
regexp-opt.  regexp-opt is preloaded (in GUI-capable builds), so we
should have regexp-opt.eln under native-lisp/ directory, but it is not
actually preloaded in --without-x builds.  And regexp-opt (the
function) calls regexp-opt-group.  So it sounds like when
regexp-opt.eln is auto-loaded on Han's platform, it signals this
error, for some reason, although regexp-opt-group is defined inside
regexp-opt.el.  Some bug in libgccjit on OpenBSD, perhaps, or in GCC
11 on that OS?  Or something else, perhaps because regexp-opt.eln is
in preloaded/, but not actually preloaded into --without-x builds?

Andrea, how to continue investigating this?  This bug is currently the
only blocker that prevents us from going to the first pretest of Emacs
28, so it's quite frustrating that we cannot solve it for the past 12
days.  If we cannot resolve this quickly, I'm tempted to ignore this
problem as something specific to OpenBSD, since my own build
"--without-x" (on GNU/Linux) doesn't have this problem.

Thanks.