Skip to content

tools/bashreadline: Fix bashreadline #4903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

sancppp
Copy link
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
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
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
martinetd added a commit to martinetd/nixpkgs that referenced this pull request Jul 21, 2024
- 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: NixOS#328743
dkruces pushed a commit to dkruces/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
dkruces pushed a commit to dkruces/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.
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