Skip to content

Fix infinite loop on obsolete function aliases#368

Open
kovan wants to merge 2 commits intoWilfred:masterfrom
kovan:fix/obsolete-alias-infinite-loop
Open

Fix infinite loop on obsolete function aliases#368
kovan wants to merge 2 commits intoWilfred:masterfrom
kovan:fix/obsolete-alias-infinite-loop

Conversation

@kovan
Copy link
Copy Markdown

@kovan kovan commented Feb 27, 2026

Fixes #365helpful-callable hangs at 100% CPU on obsolete aliases due to missing cycle detection in indirect-function and find-function-library calls.

Adds helpful--safe-indirect-function with cycle detection (seen-list), depth limiting (max 10), and condition-case for void-function/cyclic-function-indirection. Updated 5 call sites.

Verified on Emacs 30.2: void alias returns nil safely; cycle detection, depth limit, and condition-case all confirmed present.

When helpful-callable is called on a symbol defined via
define-obsolete-function-alias, the alias chain can be cyclic or
point to a void function.  This caused hangs because:

- find-function-library (Emacs built-in) has its own alias-following
  loop without cycle detection, causing 100% CPU on cyclic aliases
- indirect-function calls could hang on cycles in older Emacs
  versions or error on void targets
- helpful--canonical-symbol called symbol-function without checking
  fboundp, crashing on void alias targets

Add helpful--safe-indirect-function that resolves function
indirection with cycle detection, depth limiting, and void-function
handling.  Use it to replace bare indirect-function calls in
helpful--edebug-p, helpful--primitive-p, and helpful--source.
Guard the find-function-library call with a cycle check to prevent
infinite loops in the Emacs built-in code.

Fix: Wilfred#365

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@kovan kovan marked this pull request as draft February 27, 2026 00:23
@kovan kovan marked this pull request as ready for review February 27, 2026 00:25
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

helpful-callable hangs with 100% CPU

1 participant