dspinellis / dspinellis/ai-cli-lib

Consider safer injection method

Open
#18 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
210
Forks
16
PR merge metrics
No merged PRs in 30d

Description

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_.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.