Skip to content
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

Consider safer injection method #18

Open
dspinellis opened this issue Oct 8, 2024 · 0 comments
Open

Consider safer injection method #18

dspinellis opened this issue Oct 8, 2024 · 0 comments

Comments

@dspinellis
Copy link
Owner

Rather than using __attribute__((constructor)), which is called early in the program's initialization sequence (before the call to main), make the library be a readline(3) replacement, and call dlsym(RTLD_NEXT, "readline") after injecting the AI query behavior.

This will avoid the problem where with GNU awk ai-cli-lib calls malloc(3) before the awk code has called the required pma_init(3), thus leading to a fatal malloc(3) failure. This proposal was inspired by Terence Kelly's suggestion to avoid calling constructor-like functions before main.

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

No branches or pull requests

1 participant