Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak(s) when modifying PATH in various contexts #405

Open
McDutchie opened this issue Dec 27, 2021 · 2 comments
Open

Memory leak(s) when modifying PATH in various contexts #405

McDutchie opened this issue Dec 27, 2021 · 2 comments
Labels
bug Something is not working

Comments

@McDutchie
Copy link

McDutchie commented Dec 27, 2021

These regression tests leak:

TEST title='set PATH attribute in main shell' known=y url=https://github.com/ksh93/ksh/issues/405
DO
typeset -A PATH
unset PATH
PATH=$save_PATH
hash "${random_utils[@]}"
DONE
TEST title='unset PATH in main shell' known=y url=https://github.com/ksh93/ksh/issues/405
DO
unset PATH
PATH=$save_PATH
hash "${random_utils[@]}"
DONE
TEST title='set PATH value in subshell' known=y url=https://github.com/ksh93/ksh/issues/405
DO
(PATH=/dev/null)
DONE
TEST title='run command with preceding PATH assignment in subshell' known=y url=https://github.com/ksh93/ksh/issues/405
DO
(PATH=/dev/null command true)
DONE
TEST title='set PATH attribute in subshell' known=y url=https://github.com/ksh93/ksh/issues/405
DO
(readonly PATH)
DONE
TEST title='unset PATH in subshell' known=y url=https://github.com/ksh93/ksh/issues/405
DO
(unset PATH)
DONE

I don't know if these are all different leaks, all the same leak, or neither.

Relevant results on macOS when running DEBUG=y bin/shtests -p leaks:

	leaks.sh[368]: FAIL: known leak: unset PATH in main shell: leaked approx 6596 KiB after 16384 iterations -- help us fix it at: https://github.com/ksh93/ksh/issues/405
	leaks.sh[379]: FAIL: known leak: set PATH value in subshell: leaked approx 9140 KiB after 16384 iterations -- help us fix it at: https://github.com/ksh93/ksh/issues/405
	leaks.sh[384]: FAIL: known leak: run command with preceding PATH assignment in subshell: leaked approx 748 KiB after 16384 iterations -- help us fix it at: https://github.com/ksh93/ksh/issues/405
	leaks.sh[389]: FAIL: known leak: set PATH attribute in subshell: leaked approx 9596 KiB after 16384 iterations -- help us fix it at: https://github.com/ksh93/ksh/issues/405
	leaks.sh[394]: FAIL: known leak: unset PATH in subshell: leaked approx 15964 KiB after 16384 iterations -- help us fix it at: https://github.com/ksh93/ksh/issues/405
@McDutchie McDutchie added the bug Something is not working label Dec 27, 2021
@McDutchie McDutchie changed the title Memory leak(s) when assigning to PATH in various contexts Memory leak(s) when modifying PATH in various contexts Dec 27, 2021
@atheik

This comment was marked as outdated.

@atheik

This comment was marked as outdated.

atheik added a commit to atheik/ksh that referenced this issue Mar 27, 2022
src/cmd/ksh93/sh/subshell.c: nv_subsaved():
- Before freeing node, check whether the corresponding dictionary
  entry has a discipline function and free it if applicable.

Progresses: ksh93#405
atheik added a commit to atheik/ksh that referenced this issue Mar 27, 2022
src/cmd/ksh93/sh/subshell.c: nv_subsaved():
- Before freeing list item, check whether the node in its dictionary
  entry has a discipline function and free it if it is designated to be
  freed.

Progresses: ksh93#405
atheik added a commit to atheik/ksh that referenced this issue Apr 5, 2022
src/cmd/ksh93/sh/path.c:
- Stop calling path_dup() on defpathinit() return value as it
  immediately raises the reference count of the path components to 2
  and makes it such that a single path_delete() is not sufficient for
  freeing the path components. The path_dup() call in path_addpath()
  which caused the leak was last strictly necessary probably in ksh93o.

Progresses: ksh93#405
atheik added a commit to atheik/ksh that referenced this issue Apr 5, 2022
src/cmd/ksh93/sh/array.c:
- ???

Progresses: ksh93#405
atheik added a commit to atheik/ksh that referenced this issue Jun 20, 2022
src/cmd/ksh93/sh/subshell.c: nv_subsaved():
- Before freeing list item, check whether the node in its dictionary
  entry has a discipline function and free it if it is designated to be
  freed.

Progresses: ksh93#405
atheik added a commit to atheik/ksh that referenced this issue Jun 20, 2022
src/cmd/ksh93/sh/path.c:
- Stop calling path_dup() on defpathinit() return value as it
  immediately raises the reference count of the path components to 2
  and makes it such that a single path_delete() is not sufficient for
  freeing the path components. The path_dup() call in path_addpath()
  which caused the leak was last strictly necessary probably in ksh93o.

Progresses: ksh93#405
atheik added a commit to atheik/ksh that referenced this issue Jun 20, 2022
src/cmd/ksh93/sh/array.c:
- ???

Progresses: ksh93#405
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working
Projects
None yet
Development

No branches or pull requests

2 participants