Skip to content

Consider safer injection method #18

@dspinellis

Description

@dspinellis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions