greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, packages, and more.
https://www.racket-mode.com/
GNU General Public License v3.0
682 stars 93 forks source link

With xp-mode enabled, Emacs hangs indefinitely on simple code #609

Closed sarna closed 2 years ago

sarna commented 2 years ago

Hi!

I really appreciate you working on this package, in most cases it works really well and it's made programming in Racket very pleasant for me :)

I have no idea what's wrong, but my Emacs started hanging with xp-mode enabled even on the simplest code (hello world). Emacs will stop responding to anything, including C-g and SIGUSR2. The only way to get it back is to kill it and start again. I tried enabling debug mode, there were no messages before the hang. Once I managed to catch this:

Screen Shot 2022-04-03 at 19 19 40

I installed paren-face package and enabled its global mode, didn't help at all.

To reproduce:

  1. Make sure xp-mode is enabled
  2. For faster results, type half a function's name and let the completion popup appear
  3. Cycle through the completions a couple times (sometimes docs will appear sometimes not), write a couple lines of code
  4. Emacs will stop responding
((alist-get 'racket-mode package-alist))
((emacs-version "27.2")
 (system-type darwin)
 (x-gtk-use-system-tooltips UNDEFINED)
 (major-mode racket-mode)
 (racket--el-source-dir "/Users/sarna/.emacs.d/.local/straight/build-27.2/racket-mode/")
 (racket--rkt-source-dir "/Users/sarna/.emacs.d/.local/straight/build-27.2/racket-mode/racket/")
 (racket-program "racket")
 (racket-command-timeout 10)
 (racket-path-from-emacs-to-racket-function UNDEFINED)
 (racket-path-from-racket-to-emacs-function UNDEFINED)
 (racket-browse-url-function racket-browse-url-using-temporary-file)
 (racket-documentation-search-location "https://docs.racket-lang.org/search/index.html?q=%s")
 (racket-xp-after-change-refresh-delay 1)
 (racket-xp-mode-lighter
  (:eval
   (racket--xp-mode-lighter)))
 (racket-xp-highlight-unused-regexp "^[^_]")
 (racket-repl-buffer-name-function nil)
 (racket-submodules-to-run
  ((test)
   (main)))
 (racket-memory-limit 2048)
 (racket-error-context medium)
 (racket-repl-history-directory "~/.emacs.d/.local/etc/racket-mode/")
 (racket-history-filter-regexp "\\`\\s *\\'")
 (racket-images-inline t)
 (racket-imagemagick-props nil)
 (racket-images-keep-last 100)
 (racket-images-system-viewer "open")
 (racket-pretty-print t)
 (racket-use-repl-submit-predicate nil)
 (racket-pretty-print t)
 (racket-indent-curly-as-sequence t)
 (racket-indent-sequence-depth 0)
 (racket-pretty-lambda nil)
 (racket-smart-open-bracket-enable nil)
 (racket-module-forms "\\s(\\(?:module[*+]?\\|library\\)")
 (racket-logger-config
  ((cm-accomplice . warning)
   (GC . info)
   (module-prefetch . warning)
   (optimizer . info)
   (racket/contract . error)
   (sequence-specialization . info)
   (* . fatal)))
 (racket-show-functions
  (racket-show-pseudo-tooltip)))
(enabled-minor-modes
 (+popup-mode)
 (all-the-icons-completion-mode)
 (auto-composition-mode)
 (auto-compression-mode)
 (auto-encryption-mode)
 (auto-fill-mode)
 (auto-save-mode)
 (better-jumper-local-mode)
 (better-jumper-mode)
 (column-number-mode)
 (company-box-mode)
 (company-mode)
 (display-line-numbers-mode)
 (display-time-mode)
 (doom-modeline-mode)
 (dtrt-indent-mode)
 (electric-indent-mode)
 (emojify-mode)
 (evil-escape-mode)
 (evil-goggles-mode)
 (evil-local-mode)
 (evil-mode)
 (evil-snipe-local-mode)
 (evil-snipe-mode)
 (evil-snipe-override-local-mode)
 (evil-snipe-override-mode)
 (evil-surround-mode)
 (file-name-shadow-mode)
 (flycheck-mode)
 (flycheck-popup-tip-mode)
 (font-lock-mode)
 (format-all-mode)
 (gcmh-mode)
 (general-override-mode)
 (global-company-mode)
 (global-eldoc-mode)
 (global-emojify-mode)
 (global-evil-surround-mode)
 (global-flycheck-mode)
 (global-font-lock-mode)
 (global-git-commit-mode)
 (global-hl-line-mode)
 (global-so-long-mode)
 (global-subword-mode)
 (global-undo-fu-session-mode)
 (highlight-numbers-mode)
 (highlight-quoted-mode)
 (hl-line-mode)
 (hl-todo-mode)
 (hs-minor-mode)
 (line-number-mode)
 (marginalia-mode)
 (mouse-wheel-mode)
 (ns-auto-titlebar-mode)
 (override-global-mode)
 (persp-mode)
 (projectile-mode)
 (racket-smart-open-bracket-mode)
 (racket-xp-mode)
 (rainbow-delimiters-mode)
 (recentf-mode)
 (save-place-mode)
 (savehist-mode)
 (semantic-minor-modes-format)
 (shell-dirtrack-mode)
 (show-paren-mode)
 (size-indication-mode)
 (smartparens-global-mode)
 (smartparens-mode)
 (solaire-global-mode)
 (subword-mode)
 (transient-mark-mode)
 (undo-fu-mode)
 (undo-fu-session-mode)
 (vertico-mode)
 (vi-tilde-fringe-mode)
 (which-key-mode)
 (whitespace-mode)
 (window-divider-mode)
 (winner-mode)
 (ws-butler-global-mode)
 (ws-butler-mode)
 (xclip-mode)
 (xterm-mouse-mode)
 (yas-global-mode)
 (yas-minor-mode))
(disabled-minor-modes
 (+emacs-lisp-ert-mode)
 (+lsp-optimization-mode)
 (+popup-buffer-mode)
 (+web-django-mode)
 (+web-jekyll-mode)
 (+web-wordpress-mode)
 (abbrev-mode)
 (archive-subfile-mode)
 (auto-fill-function)
 (auto-revert-mode)
 (auto-revert-tail-mode)
 (auto-save-visited-mode)
 (blink-cursor-mode)
 (buffer-face-mode)
 (buffer-read-only)
 (cl-old-struct-compat-mode)
 (company-search-mode)
 (compilation-minor-mode)
 (compilation-shell-minor-mode)
 (completion-in-region-mode)
 (consult-preview-at-point-mode)
 (cursor-intangible-mode)
 (cursor-sensor-mode)
 (dash-fontify-mode)
 (defining-kbd-macro)
 (diff-auto-refine-mode)
 (diff-minor-mode)
 (dired-hide-details-mode)
 (dtrt-indent-global-mode)
 (eldoc-mode)
 (electric-layout-mode)
 (electric-quote-mode)
 (emojify-debug-mode)
 (emojify-mode-line-mode)
 (evil-collection-magit-toggle-text-minor-mode)
 (flyspell-mode)
 (general-override-local-mode)
 (git-commit-mode)
 (global-auto-revert-mode)
 (global-dash-fontify-mode)
 (global-display-line-numbers-mode)
 (global-emojify-mode-line-mode)
 (global-hide-mode-line-mode)
 (global-hl-todo-mode)
 (global-prettify-symbols-mode)
 (global-reveal-mode)
 (global-semantic-highlight-edits-mode)
 (global-semantic-highlight-func-mode)
 (global-semantic-show-parser-state-mode)
 (global-semantic-show-unmatched-syntax-mode)
 (global-semantic-stickyfunc-mode)
 (global-superword-mode)
 (global-vi-tilde-fringe-mode)
 (global-visual-line-mode)
 (global-whitespace-mode)
 (global-whitespace-newline-mode)
 (hide-mode-line-mode)
 (horizontal-scroll-bar-mode)
 (ibuffer-auto-mode)
 (isearch-mode)
 (ispell-minor-mode)
 (jit-lock-debug-mode)
 (magit-auto-revert-mode)
 (magit-blame-mode)
 (magit-blame-read-only-mode)
 (magit-blob-mode)
 (magit-popup-help-mode)
 (magit-todos-mode)
 (magit-wip-after-apply-mode)
 (magit-wip-after-save-local-mode)
 (magit-wip-after-save-mode)
 (magit-wip-before-change-mode)
 (magit-wip-initial-backup-mode)
 (magit-wip-mode)
 (mail-abbrevs-mode)
 (menu-bar-mode)
 (mml-mode)
 (next-error-follow-minor-mode)
 (org-capture-mode)
 (org-cdlatex-mode)
 (org-list-checkbox-radio-mode)
 (org-src-mode)
 (org-table-follow-field-mode)
 (org-table-header-line-mode)
 (orgtbl-mode)
 (outline-minor-mode)
 (overwrite-mode)
 (paragraph-indent-minor-mode)
 (pcre-mode)
 (prettify-symbols-mode)
 (rectangle-mark-mode)
 (reveal-mode)
 (rxt--read-pcre-mode)
 (rxt-global-mode)
 (rxt-mode)
 (semantic-highlight-edits-mode)
 (semantic-highlight-func-mode)
 (semantic-mode)
 (semantic-show-parser-state-mode)
 (semantic-show-unmatched-syntax-mode)
 (semantic-stickyfunc-mode)
 (server-mode)
 (sh-electric-here-document-mode)
 (shell-command-with-editor-mode)
 (show-smartparens-global-mode)
 (show-smartparens-mode)
 (smartparens-global-strict-mode)
 (smartparens-strict-mode)
 (smerge-mode)
 (so-long-minor-mode)
 (solaire-mode)
 (superword-mode)
 (tab-bar-history-mode)
 (tab-bar-mode)
 (tar-subfile-mode)
 (temp-buffer-resize-mode)
 (text-scale-mode)
 (tool-bar-mode)
 (tooltip-mode)
 (transient-resume-mode)
 (unify-8859-on-decoding-mode)
 (unify-8859-on-encoding-mode)
 (url-handler-mode)
 (use-hard-newlines)
 (view-mode)
 (visible-mode)
 (visual-line-mode)
 (which-function-mode)
 (whitespace-newline-mode)
 (with-editor-mode)
 (xref-etags-mode))
greghendershott commented 2 years ago

That sounds bad!

  1. If I understand correctly, this happens when you make some edit that causes the completion mechanism to kick in?

  2. As a couple wild guess experiments, what if you try disabling each of these minor modes:

  1. If the problem still occurs, are there some other minor modes from your "details" that you could try disabling?
(enabled-minor-modes
 (+popup-mode)
 (all-the-icons-completion-mode)
 (auto-composition-mode)
 (auto-compression-mode)
 (auto-encryption-mode)
 (auto-fill-mode)
 (auto-save-mode)
 (better-jumper-local-mode)
 (better-jumper-mode)
 (column-number-mode)
 (company-box-mode)
 (company-mode)
 (display-line-numbers-mode)
 (display-time-mode)
 (doom-modeline-mode)
 (dtrt-indent-mode)
 (electric-indent-mode)
 (emojify-mode)
 (evil-escape-mode)
 (evil-goggles-mode)
 (evil-local-mode)
 (evil-mode)
 (evil-snipe-local-mode)
 (evil-snipe-mode)
 (evil-snipe-override-local-mode)
 (evil-snipe-override-mode)
 (evil-surround-mode)
 (file-name-shadow-mode)
 (flycheck-mode)
 (flycheck-popup-tip-mode)
 (font-lock-mode)
 (format-all-mode)
 (gcmh-mode)
 (general-override-mode)
 (global-company-mode)
 (global-eldoc-mode)
 (global-emojify-mode)
 (global-evil-surround-mode)
 (global-flycheck-mode)
 (global-font-lock-mode)
 (global-git-commit-mode)
 (global-hl-line-mode)
 (global-so-long-mode)
 (global-subword-mode)
 (global-undo-fu-session-mode)
 (highlight-numbers-mode)
 (highlight-quoted-mode)
 (hl-line-mode)
 (hl-todo-mode)
 (hs-minor-mode)
 (line-number-mode)
 (marginalia-mode)
 (mouse-wheel-mode)
 (ns-auto-titlebar-mode)
 (override-global-mode)
 (persp-mode)
 (projectile-mode)
 (racket-smart-open-bracket-mode)
 (racket-xp-mode)
 (rainbow-delimiters-mode)
 (recentf-mode)
 (save-place-mode)
 (savehist-mode)
 (semantic-minor-modes-format)
 (shell-dirtrack-mode)
 (show-paren-mode)
 (size-indication-mode)
 (smartparens-global-mode)
 (smartparens-mode)
 (solaire-global-mode)
 (subword-mode)
 (transient-mark-mode)
 (undo-fu-mode)
 (undo-fu-session-mode)
 (vertico-mode)
 (vi-tilde-fringe-mode)
 (which-key-mode)
 (whitespace-mode)
 (window-divider-mode)
 (winner-mode)
 (ws-butler-global-mode)
 (ws-butler-mode)
 (xclip-mode)
 (xterm-mouse-mode)
 (yas-global-mode)
 (yas-minor-mode))
  1. I notice you use straight.el; can you please let me know what commit from the main branch for Racket mode?

Thanks!

greghendershott commented 2 years ago

p.s. The messages about Invalid face reference: parenthesis suggest something for me to fix. However I think that's orthogonal to any freeze/crash. It does however tell me that documentation is being requested -- maybe by company-box-mode?? -- and that is successful at least up to that point where this warning might appear... which is possibly useful to know.

sarna commented 2 years ago
  1. It seems to trigger most often in this position (define (foo) |) (| is cursor) when I type an opening paren (to make it (define (foo) ())). But there's no rule, and triggering completion a couple times seems to make it trigger faster/more frequently. Like, after triggering after writing half a page of code it'll trigger in the first function I try to write. Right now I managed it to hang like this:
    1. Write (defin)
    2. Wait for autocompletion popup to fully load
    3. Hit tab so it autocompletes to (define)
    4. Hit space to write more code
    5. Hang :)
  2. Same thing without company-box-mode. When I do M-x eldoc-mode it says.. wow I managed it to hang by doing this and then by opening ibuffer to switch to *Messages* buffer. In fact, trying to open ibuffer hangs consistently. I'm starting to suspect something else than racket-mode. Anyway, the message is "There is no ElDoc support in this buffer" - so I think it's disabled already?
  3. I'll try to revert my config to an earlier version and let you know.
  4. I'm using Doom, so it's this one https://github.com/hlissner/doom-emacs/blob/86a8b41e37ecc471ba92135fa67aa27f9cf24f8f/modules/lang/racket/packages.el#L4
sarna commented 2 years ago

I did some more testing and it 100% looks like something with my config, out of the box racket-mode works great, even better with company-box-mode. No hangs. I'll keep digging and update when I find the culprit.

sarna commented 2 years ago

Seems like I'm having the same issue as people here: https://github.com/mickeynp/ligature.el/issues/10

It's not coming from racket-mode, sorry for not checking thoroughly before. Thank you very much for your assistance :)

greghendershott commented 2 years ago

No worries! At least it made me aware of #610, which I merged.

Your mention of ligatures jogged my memory; it sounds like this is related to #523. IIUC it should be OK using Emacs 28+.

sarna commented 2 years ago

Yes, exactly: I had a composition-function-table in my config as well! I'll wait for a new release with adding it again. Thanks a ton :)