Skip to content

fix(editor): prefix search and suggestion keys on non-PIE builds - #179

Merged
LESdylan merged 1 commit into
developfrom
fix/rl-slot-named-functions
Oct 18, 2026
Merged

LESdylan merged 1 commit into
developfrom
fix/rl-slot-named-functions

Conversation

@LESdylan

Copy link
Copy Markdown
Member

On the 42 machines none of #136's / #140's keys were installed: Up stayed plain history; Right / End / ^F / Alt-F / Alt-N ignored the ghost.

Root cause: rl_slot_arm() compares the function in a slot with readline's stock one, taken by address. cc there is clang 12 (non-PIE), so &rl_get_previous_history is the PLT stub, while Ubuntu's -Bsymbolic-functions libreadline keeps its internal address in the keymaps. Never equal → every slot looked user-bound. CI (gcc, PIE) and the static release can't show it.

Fix: rl_slot_funcs() gets readline's functions with rl_named_function(), for the stock side and for the history-search pair (whose rl_last_func check also needs the real pointer to walk back on repeated Up).

Non-PIE debug build, both readers:

test before after
history_prefix_search_test 57 failed 148 ok, 1 failed*
autosuggest_test 86 failed 346 ok, 0 failed

* bind -p vs the oracle's bundled readline 8.3; fails on develop too.

Follow-up worth considering: a non-PIE CI job running these two tests.

🤖 Generated with Claude Code

On the 42 machines Up stayed plain history and Right / End / ^F / Alt-F
/ Alt-N never touched the ghost: none of #136's or #140's keys were
installed. rl_slot_arm() decides whether a slot still holds readline's
stock function by comparing pointers, and took the stock ones by address
(&rl_get_previous_history, ...). cc there is clang 12, which links
non-PIE, where such an address is the executable's PLT stub; Ubuntu's
libreadline is linked -Bsymbolic-functions and keeps its own internal
address in the keymaps. The two never compared equal, every slot read as
a user binding, and slot_user kept it that way for the session. gcc
(CI) and the static release build link PIE, so neither showed it.

rl_slot_funcs() now asks readline for its functions by name
(rl_named_function), the pointer its keymaps and funmap hold, for the
stock side and for the history-search pair that replaces Up / Down. The
latter also matters for readline's own rl_last_func check: a search
bound by stub address would restart on every Up instead of walking back.

Verified on a non-PIE debug build (file: "LSB executable"), both readers:
history_prefix_search_test 57 failed -> 148 ok / 1 failed, the one being
bind -p against the oracle's bundled readline 8.3 (fails on develop
too); autosuggest_test 86 failed -> 346 ok / 0 failed. A PIE build passes
before and after, so CI cannot see this without a non-PIE job.
@LESdylan
LESdylan merged commit 985047b into develop Oct 18, 2026
35 checks passed
@LESdylan
LESdylan deleted the fix/rl-slot-named-functions branch October 18, 2026 02:27
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.

1 participant