Skip to content

Commit 8ebd422

Browse files
committed
Avoid breaking GNU awk with pma support
1 parent 21a35b8 commit 8ebd422

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/ai_cli.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,23 @@ setup(void)
143143
if (dlerror())
144144
return; // Program not linked with readline(3)
145145

146+
/*
147+
* GNU awk 5.2.1 under Debian bookworm and maybe also other
148+
* versions is distributed with a persistent memory allocator (PMA)
149+
* library, which requires initialization with pma_init
150+
* before using it. If the allocator is not initialized calls
151+
* to malloc will (such as those * made by rl_add_defun() in this
152+
* function) will fail with a fatal error, such as the following.
153+
* (null): fatal: node.c:1075:more_blocks: freep: cannot allocate
154+
* 11200 bytes of memory: [unrelated error message]
155+
* To avoid this problem, exit if called from awk.
156+
* In the future more programs may need to get deny-listed here.
157+
*/
158+
const char *program_name = acl_short_program_name();
159+
if (strcmp(program_name, "awk") == 0
160+
|| strcmp(program_name, "gawk") == 0)
161+
return;
162+
146163
// Obtain remaining variable symbols
147164
rl_end_ptr = dlsym(RTLD_DEFAULT, "rl_end");
148165
rl_point_ptr = dlsym(RTLD_DEFAULT, "rl_point");

0 commit comments

Comments
 (0)