nameref, varnames, evalstring can unload loadables while they are being
From:
Emanuele Torre
Subject:
nameref, varnames, evalstring can unload loadables while they are being run
Date:
Tue, 28 Nov 2023 08:13:26 +0100
User-agent:
Mutt/2.2.12 (2023-09-09)
I have notices that funsubs can be used to unload loadable builtins
while they are being run e.g.
bash-5.3$ enable -f {examples/loadables/,}mktemp
bash-5.3$ declare -n foo='q[${| enable -d mktemp;}0]'
bash-5.3$ mktemp -v foo
/tmp/shtmp.jKcUE0
Segmentation fault (core dumped)
This problem also affects loadable builtin that have varname arguments
instead of variable identifiers, and builtins that have `mapfile-C'-like
callbacks, or otherwise use evalstring().
I think it would be nice if bash would be able to know which be able to
know which loadable builtins are currently being executed, and make
enable -d fail for those loadables instead of letting it unload code
that will be executed later when evalstring()/find_variable()/etc
returns.
o/
emanuele6