Subject: bug#49507: 28.0.50; macOS: Symbol’s value as variable is void: lock-file-name-transforms

From: Naofumi Yasufuku <[email-masked]>
Date: Fri, 16 Jul 2021 23:07:06 +0900

Lars Ingebrigtsen <[email-masked]> writes:
>
> I've now removed the :initialize form from the defcustom, so the build
> should work better now.  (I'll be filing a new bug report about
> :initialize 'custom-initialize-delay in general.)

Thank you, Lars and everyone.
Sorry for my absence.  I confirmed that 'LANG=ja_JP.UTF-8 emacs' starts
up without error after commit 561ef16fd0.

I agree that defcustom `custom-initialize-delay' implementation issue
still remains, and this workaround lacks a bit of consistency of
`make-lock-file-name' with custom `lock-file-name-transforms' variable.

In closing, let me summarize this issue:

--------
$ ./configure --with-native-compilation ...
$ make -j8 bootstrap

STEP 0)
Make sure that ~/.emacs/eln-cache doesn't exist.
Remove or rename it if exists.

$ mv ~/.emacs/eln-cache ~/.emacs/eln-cache.old

STEP 1)
Run emacs with $LANG that can invoke async native compilation
of lisp/language/*-util.el.

$ LANG=ja_JP.UTF-8 ./src/emacs -Q
Symbol’s value as variable is void: lock-file-name-transforms
$
$ LANG=zh_CN.UTF-8 ./src/emacs -Q
Symbol's value as variable is void: lock-file-name-transforms
$
$ ls
aclocal.m4             configure.ac                           lwlib
admin                  CONTRIBUTE                             m4
autogen.sh             COPYING                                make-dist
autom4te.cache         doc                                    Makefile
BUGS                   emacs-async-comp-china-util-C75DZz.el  Makefile.in
build-aux              emacs-async-comp-japan-util-eJHmFp.el  modules
ChangeLog.1            etc                                    msdos
ChangeLog.2            GNUmakefile                            native-lisp
ChangeLog.3            info                                   nextstep
compile_commands.json  INSTALL                                nt
config.bat             INSTALL.REPO                           oldXMenu
config.log             leim                                   README
config.log~            lib                                    src
config.status          lib-src                                test
configure              lisp
$

TRACE)
This error can happen if `write-region' by async native compilation runs
at early stage of emacs startup.  Not macOS-specific.

$ cd src
$ export LANG=ja_JP.UTF-8
$ gdb emacs
..
Breakpoint 1 at 0x1000d3a00: terminate_due_to_signal. (2 locations)
(gdb) b make_lock_file_name
Breakpoint 2 at 0x100100aa8: make_lock_file_name. (3 locations)
(gdb) r -Q
Starting program: /home/naofumi/src/git.sv.gnu.org/emacs/src/emacs -Q
[New Thread 0x2303 of process 36192]
[New Thread 0x2203 of process 36192]
warning: unhandled dyld version (17)
[New Thread 0x1907 of process 36192]
[New Thread 0x2003 of process 36192]
[New Thread 0x2103 of process 36192]

Thread 2 hit Breakpoint 2, make_lock_file_name (fn=XIL(0x14562c9a4))
    at filelock.c:625
625	  return call1 (Qmake_lock_file_name, Fexpand_file_name (fn, Qnil));
(gdb) bt
#0  make_lock_file_name (fn=XIL(0x14562c9a4)) at filelock.c:625
#1  lock_file (fn=XIL(0x14562c9a4)) at filelock.c:666
#2  Flock_file (file=XIL(0x14562c9a4)) at filelock.c:755
#3  0x000000010010c9b5 in write_region (start=<optimized out>,
    end=<optimized out>, filename=<optimized out>, append=<optimized out>,
    visit=make_fixnum(0), lockname=<optimized out>, mustbenew=XIL(0), desc=10)
    at fileio.c:5230
...
Lisp Backtrace:
"write-region" (0xefbfdd58)
"comp-run-async-workers" (0xefbfdf10)
"native--compile-async" (0xefbfe180)
"defalias" (0xefbfe250)
"set-language-environment" (0xefbfeac8)
"set-locale-environment" (0xefbfee88)
"normal-top-level" (0xefbfef30)
(gdb) s
Symbol’s value as variable is void: lock-file-name-transforms
[Inferior 1 (process 36192) exited with code 0377]
(gdb) q

EXPECTED BEHAVIOR)
Emacs starts up and async native compilation runs without error
like this:

*Async-native-compile-log*
--------
Compiling /home/naofumi/src/git.sv.gnu.org/emacs/lisp/language/japan-util.el...
Compiling /home/naofumi/src/git.sv.gnu.org/emacs/lisp/emacs-lisp/cl-lib.el...
Compiling /home/naofumi/src/git.sv.gnu.org/emacs/lisp/emacs-lisp/seq.el...
...
--------

AN INTERIM WORKAROUND 1)
Specify LANG=C or en_US

$ LANG=en_US.UTF-8 ./src/emacs -Q
$

AN INTERIM WORKAROUND 2)
--------
 lisp/files.el | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lisp/files.el b/lisp/files.el
index 0dfcab8f89..894a06e6e7 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -424,7 +424,6 @@ lock-file-name-transforms
   :type '(repeat (list (regexp :tag "Regexp")
                        (string :tag "Replacement")
 		       (boolean :tag "Uniquify")))
-  :initialize 'custom-initialize-delay
   :version "28.1")
 
 (defvar auto-save--timer nil "Timer for `auto-save-visited-mode'.")
--------

In GNU Emacs 28.0.50 (build 1, aarch64-unknown-linux-gnu, GTK+ Version 3.24.25, cairo version 1.16.0)
 of 2021-07-16 built on phoebe
Repository revision: 865535a24cd07efee3c2d323de6e9baae8bc817d
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101001
System Description: Ubuntu 21.04

Configured using:
 'configure --prefix=/home/naofumi/.local/emacs-head --with-mailutils
 --with-native-compilation --with-xwidgets'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBSELINUX LIBSYSTEMD LIBXML2 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 $LANG: ja_JP.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-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:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source eieio eieio-core eieio-loaddefs
password-cache json map text-property-search 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 comp
comp-cstr warnings subr-x rx cl-seq cl-macs cl-extra help-mode seq
byte-opt gv cl-loaddefs cl-lib bytecomp byte-compile cconv iso-transl
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
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 elisp-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 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 lcms2 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 73557 8376)
 (symbols 48 7820 1)
 (strings 32 21016 3598)
 (string-bytes 1 690372)
 (vectors 16 17084)
 (vector-slots 8 281899 11071)
 (floats 8 27 36)
 (intervals 56 218 0)
 (buffers 992 12))