This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 317861990cb08f6628d3786b7058c2ef6287e2b0 Author: Marco Casaroli <[email protected]> AuthorDate: Mon Oct 12 05:32:14 2026 +0200 binfmt: Keep the unload method of the module that a script loads. load_absmodule() saves the unload method of the handler that loaded the file. The script handler loads the interpreter through load_module(), which saves the interpreter's method, and then the outer loop replaced it with the script handler's NULL method. unload_module() then did not call libelf_uninit(): the destructors of the interpreter did not run, and its symbol table, and in a flat build its text and data, were never freed. Save the method only if the handler has one. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- binfmt/binfmt_loadmodule.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/binfmt/binfmt_loadmodule.c b/binfmt/binfmt_loadmodule.c index 57f7c073194..1d20f2e0ef7 100644 --- a/binfmt/binfmt_loadmodule.c +++ b/binfmt/binfmt_loadmodule.c @@ -129,9 +129,16 @@ static int load_absmodule(FAR struct binary_s *bin, FAR const char *filename, strlcpy(bin->fname, filename, sizeof(bin->fname)); #endif - /* Save the unload method for use by unload_module */ + /* Save the unload method for use by unload_module. A handler + * without one that loaded another module through load_module() + * (a script loads its interpreter) keeps that module's method. + */ + + if (binfmt->unload != NULL) + { + bin->unload = binfmt->unload; + } - bin->unload = binfmt->unload; binfmt_dumpmodule(bin); break; }
