Subject: 25.3; Emacs aborts with fatal error when a keyboard macro (saved in init.el) is set to run automatically at Emacs startup (Windows 10)
From: [email-masked]
To: [email-masked]
Date: Wed, 11 Nov 2020 23:51:01 +0530
List-Id: <debbugs-submit.debbugs.gnu.org>

In GNU Emacs 25.3.1 (x86_64-w64-mingw32)
 of 2017-09-17 built on LAPHROAIG
Windowing system distributor 'Microsoft Corp.', version 10.0.17134
Configured using:
 'configure --without-dbus --without-compress-install 'CFLAGS=-O2
 -static -g3''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Lisp Interaction

Minor modes in effect:
  savehist-mode: t
  save-place-mode: t
  tooltip-mode: t
  global-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
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  global-visual-line-mode: t
  visual-line-mode: t
  transient-mark-mode: t

Recent messages:
Starting Emacs daemon.
When done with this frame, type C-x 5 0

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message idna dired format-spec rfc822
mml mml-sec password-cache epg gnus-util mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util help-fns mail-prsvr mail-utils server
time-date imenu finder-inf edmacro kmacro package epg-config seq
byte-opt gv bytecomp byte-compile cl-extra help-mode easymenu cconv
cl-loaddefs pcase cl-lib savehist saveplace mule-util tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type mwheel dos-w32
ls-lisp disp-table w32-win w32-vars term/common-win tool-bar dnd fontset
image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame 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 charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote w32notify w32 multi-tty
make-network-process emacs)

Memory information:
((conses 16 228843 16607)
 (symbols 56 25882 0)
 (miscs 48 52 128)
 (strings 32 63017 18885)
 (string-bytes 1 1525123)
 (vectors 16 19795)
 (vector-slots 8 536167 4328)
 (floats 8 193 3)
 (intervals 56 763 30)
 (buffers 976 20))

Hello,

I encountered a fatal error which caused Emacs to abort at startup
(running as Daemon). The actions which led to this bug are as follows:

1. I recorded a keyboard macro and inserted its elisp code in init.el
with the M-x insert-kbd-macro function.

2. The elisp code for the macro is

;; This macro automatically runs remember-notes on Emacs startup and
;; then runs recover-this-file to recover autosave data of notes and
;; then enters 'yes' to the minibuffer prompt
(fset 'remember-notes-my-macro
   (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([134217848 114 101 109 101 109 98 101 114 45 110 111 116 101 115 return 134217848 114 101 99 111 118 101 114 45 116 104 105 115 45 102 105 108 101 return 121 101 115 return] 0 "%d")) arg)))
;; Macro ends here

3. I wished for this macro execute automatically when Emacs Daemon is
launched at System startup. So I added the following line to my init.el

(remember-notes-my-macro)

4. When Emacs is started, I get a dialog box with the following text:

QUOTE
A fatal error has occured!
Would you like to attach a debugger?
Select:
YES -- To debug Emacs, or
NO -- to abort Emacs and produce a backtrace
(emacs_backtrace.txt in current directory).
(type 'gdb -p <emacs-PID>' and
'continue' inside GDB before clicking YES.)
UNQUOTE

5. However, this macro RUNS FINE when invoked in a running Emacs
instance by M-x remember-notes-my-macro

6. Please find the emacs_backtrace.txt in the attachment to this email.
<#part type=text filename="c:/Users/USER/Desktop/emacs_backtrace.txt" disposition=inline description=emacs_backtrace.txt>
<#/part>

Warm regards,
Akshay