~ chicken-core (chicken-5) ff8a66a7bb180d7dce6c9a6d7cb3e5d6cb53c985
commit ff8a66a7bb180d7dce6c9a6d7cb3e5d6cb53c985 Author: Peter Bex <peter@more-magic.net> AuthorDate: Thu Jul 22 13:22:00 2021 +0200 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Thu Jul 22 14:13:17 2021 +0200 Use merge-se, not append in ##sys#import to fix memory leak (#1772) Using append on the current module (meta) environment in "import" will extend the environment correctly, but it will grow the list. Instead, we want to replace add those bindings which are new (and possibly replace existing bindings of the same name). This is what merge-se was made for. This potentially slows down performance on import, but should be relatively harmless. Signed-off-by: felix <felix@call-with-current-continuation.org> diff --git a/NEWS b/NEWS index e65f885a..060a9d0e 100644 --- a/NEWS +++ b/NEWS @@ -81,6 +81,10 @@ - Fixed bug in chicken-install regarding variable quotation on UNIX-like systems which prevented installation into paths with spaces (#1685). +- Module system + - Fixed a memory leak when calling (import) multiple times in a row + on the same module (#1772; reported by "plugd" on IRC). + 5.2.0 - Core libraries diff --git a/modules.scm b/modules.scm index 0ba1df49..d91178ff 100644 --- a/modules.scm +++ b/modules.scm @@ -820,8 +820,8 @@ cm (merge-se (module-iexports cm) vsi)) (dm "export-list: " (module-export-list cm))) - (import-env (append vsv (import-env))) - (macro-env (append vss (macro-env))))) + (import-env (merge-se (import-env) vsv)) + (macro-env (merge-se (macro-env) vss)))) (define (module-rename sym prefix) (##sys#string->symbolTrap