Skip to content

tools/bashreadline: Fix bashreadline#4903

Merged
yonghong-song merged 1 commit into
iovisor:masterfrom
sancppp:fix-bashreadline
Feb 7, 2024
Merged

tools/bashreadline: Fix bashreadline#4903
yonghong-song merged 1 commit into
iovisor:masterfrom
sancppp:fix-bashreadline

Conversation

@sancppp
Copy link
Copy Markdown
Contributor

@sancppp sancppp commented Feb 6, 2024

This Pull Request fixes the issue where the bashreadline tool would lose the first bash command upon startup.

At runtime, bash blocks at the readline function in bash::readline.c. Upon receiving the Enter key signal, it calls the readline_internal_teardown function to retrieve the user's input. Therefore, changing the hook function from readline to readline_internal_teardown resolves the issue of losing the first bash command after startup of bashreadline.

The specific approach is to open the symbol table of bash and check if there is a symbol for readline_internal_teardown function. If not, continue to use the readline function as the hook position.

@yonghong-song
Copy link
Copy Markdown
Collaborator

Could you give more details about how to reproduce lose the first bash command upon startup? That is, give a sequence of commands where the result will be different with vs. without your patch.

@sancppp
Copy link
Copy Markdown
Contributor Author

sancppp commented Feb 6, 2024

Could you give more details about how to reproduce lose the first bash command upon startup? That is, give a sequence of commands where the result will be different with vs. without your patch.

bashreadline1.mp4
bashreadline2.mp4

@yonghong-song yonghong-song merged commit 706ec4f into iovisor:master Feb 7, 2024
@sancppp sancppp deleted the fix-bashreadline branch February 7, 2024 23:13
dagomez137 pushed a commit to dagomez137/bcc that referenced this pull request Nov 28, 2024

This Pull Request fixes the issue where the bashreadline tool would lose the first bash command upon startup.

At runtime, bash blocks at the readline function in bash::readline.c. Upon receiving the Enter key signal, it calls the readline_internal_teardown function to retrieve the user's input. Therefore, changing the hook function from readline to readline_internal_teardown resolves the issue of losing the first bash command after startup of bashreadline.

The specific approach is to open the symbol table of bash and check if there is a symbol for readline_internal_teardown function. If not, continue to use the readline function as the hook position.
Mic92 pushed a commit to NixOS/nixpkgs that referenced this pull request Jan 19, 2025
- we didn't provide the newly required elfutils python dependency,
but we're only dealing with newer bashes so just use the new symbol
- while here also default to using our libreadline as bash is configured
to use it on nixos; this can still be overriden

Link: iovisor/bcc#4903
Fixes: #328743
dagomez137 pushed a commit to dagomez137/bcc that referenced this pull request Mar 18, 2025

This Pull Request fixes the issue where the bashreadline tool would lose the first bash command upon startup.

At runtime, bash blocks at the readline function in bash::readline.c. Upon receiving the Enter key signal, it calls the readline_internal_teardown function to retrieve the user's input. Therefore, changing the hook function from readline to readline_internal_teardown resolves the issue of losing the first bash command after startup of bashreadline.

The specific approach is to open the symbol table of bash and check if there is a symbol for readline_internal_teardown function. If not, continue to use the readline function as the hook position.
dagomez137 pushed a commit to dagomez137/bcc that referenced this pull request Oct 9, 2025

This Pull Request fixes the issue where the bashreadline tool would lose the first bash command upon startup.

At runtime, bash blocks at the readline function in bash::readline.c. Upon receiving the Enter key signal, it calls the readline_internal_teardown function to retrieve the user's input. Therefore, changing the hook function from readline to readline_internal_teardown resolves the issue of losing the first bash command after startup of bashreadline.

The specific approach is to open the symbol table of bash and check if there is a symbol for readline_internal_teardown function. If not, continue to use the readline function as the hook position.
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.

2 participants