Skip to content

Instantly share code, notes, and snippets.

@CyberShadow
Created February 9, 2023 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CyberShadow/6b1adfcc139cd9d52bf9f8d379999486 to your computer and use it in GitHub Desktop.
Save CyberShadow/6b1adfcc139cd9d52bf9f8d379999486 to your computer and use it in GitHub Desktop.
Reproducer for weird Emacs bug
FROM docker.io/debian:unstable-20230208@sha256:b2f6fc00701e0d5ee6ef994891a6b4695865b51292fa2fb7a34882c15c7e4b4f
RUN apt-get update
RUN apt-get install -y emacs tmux
COPY repro.sh /
CMD /repro.sh
#!/bin/bash
set -xeEuo pipefail
emacs --version
rm -rf bug
mkdir bug
cd bug
# Ensure Emacs and tmux run in our little sandbox and don't interfere with the system
export HOME=$PWD
export TMUX_TMPDIR=$PWD
export XDG_RUNTIME_DIR=$PWD
# Create init files which cause the bug
mkdir .emacs.d
cat <<'EOF' > .emacs.d/init.el
(require 'bytecomp)
(byte-compile-file ".emacs.d/localvars.el")
(define-minor-mode dummy-mode "")
(defun turn-on-dummy-mode () (dummy-mode))
(define-globalized-minor-mode global-dummy-mode
dummy-mode turn-on-dummy-mode)
(global-dummy-mode)
EOF
cat <<'EOF' > .emacs.d/localvars.el
;; Local Variables:
;; checkdoc-symbol-words: ()
;; End:
EOF
emacs --daemon
# Start ten emacsclients (use tmux to allow them to run concurrently)
for n in $(seq 10) ; do
tmux new-session -d -s emacsbug-$n 'emacsclient -nw'
done
sleep 1
# Kill all emacsclients simultaneously
tmux kill-server
sleep 1
# Test that the bug occurs. One symptom is that the scratch buffer is cleared.
# This prints 1 if the bug occurs and 146 if the bug did not occur.
emacsclient --eval '(with-current-buffer (get-buffer "*scratch*") (point-max))'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment