Closed znichola closed 1 year ago
...
minishell$ unset LC_ALL
minishell$ unset GLIBCXX_FORCE_NEW
minishell$ unset LD_PRELOAD
minishell$ env
minishell$ export
minishell$ export test=1
[1] 870 segmentation fault valgrind --leak-check=full --show-leak-kinds=definite,indirect,possible
yes there is a SEGV
hidden in there
unset $(env | awk -F "=" '{print $1}')
to unset env all at once
*[leaks][/minishell]$ unset $(env | awk -F "=" '{print $1}')
[/minishell]$ /usr/bin/valgrind -s --leak-check=full --show-leak-kinds=definite,indirect,possible --track-origins=yes --log-file=valgrind-out.txt ./minishell
minishell: shell level is too damn high, resting to 0
minishell$ env
LD_LIBRARY_PATH=/usr/lib/debug
_=/usr/bin/valgrind
GLIBCPP_FORCE_NEW=1
PWD=/minishell
GLIBCXX_FORCE_NEW=1
LD_PRELOAD=/usr/libexec/valgrind/vgpreload_core-amd64-linux.so:/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so
SHLVL=1
minishell$ unset LD_LIBRARY_PATH
minishell$ unset _
minishell$ unset GLIBCPP_FORCE_NEW
minishell$ unset PWD
minishell$ unset GLIBCXX_FORCE_NEW
minishell$ unset LD_PRELOAD
minishell$ unset SHLVL
minishell$ env
minishell$ export
minishell$ exit
[/minishell]$
and a clean bill of health
==591== Memcheck, a memory error detector
==591== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==591== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==591== Command: ./minishell
==591== Parent PID: 1
==591==
==591==
==591== HEAP SUMMARY:
==591== in use at exit: 198,653 bytes in 211 blocks
==591== total heap usage: 2,313 allocs, 2,102 frees, 803,323 bytes allocated
==591==
==591== LEAK SUMMARY:
==591== definitely lost: 0 bytes in 0 blocks
==591== indirectly lost: 0 bytes in 0 blocks
==591== possibly lost: 0 bytes in 0 blocks
==591== still reachable: 198,653 bytes in 211 blocks
==591== suppressed: 0 bytes in 0 blocks
==591== Reachable blocks (those to which a pointer was found) are not shown.
==591== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==591==
==591== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
what if we remove all env variables, we are left with nothing, then what?