binutils-gdb/gdbsupport
Philippe Waroquiers c801f8f138 fix leak in gdb_environ
valgrind reports a leak when assigning a gdb_environ to another gdb_environ.
The memory allocated for the target gdb_environ env variables is not released.
The gdb_environ selftest reproduces the leak (see below).
Fix the leak by clearing the target gdb_environ before std::move-ing the
members.

Tested natively and re-running all tests under valgrind.

==3261873== 4,842 bytes in 69 blocks are definitely lost in loss record 6,772 of 6,839
==3261873==    at 0x483979B: malloc (vg_replace_malloc.c:393)
==3261873==    by 0x25A454: xmalloc (alloc.c:57)
==3261873==    by 0x7D1E4E: xstrdup (xstrdup.c:34)
==3261873==    by 0x7E2A51: gdb_environ::from_host_environ() (environ.cc:56)
==3261873==    by 0x66F1C8: test_reinit_from_host_environ (environ-selftests.c:78)
==3261873==    by 0x66F1C8: selftests::gdb_environ_tests::run_tests() (environ-selftests.c:285)
==3261873==    by 0x7EFC43: operator() (std_function.h:622)
=

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-11-27 21:08:24 +01:00
..
.dir-locals.el
.gitattributes
acinclude.m4
aclocal.m4
agent.cc
agent.h
alt-stack.h
array-view.h
ax.def
block-signals.h [gdb] Block SIGTERM in worker threads 2022-06-30 13:31:06 +02:00
break-common.h
btrace-common.cc internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
btrace-common.h
buffer.cc
buffer.h
buildargv.h
byte-vector.h
ChangeLog-2020-2021
check-defines.el
cleanups.cc
cleanups.h
common-debug.cc
common-debug.h
common-defs.h [gdb] Add debug_{exp,val} 2022-08-05 08:09:57 +02:00
common-exceptions.cc internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
common-exceptions.h
common-gdbthread.h
common-inferior.cc
common-inferior.h
common-regcache.cc
common-regcache.h
common-types.h
common-utils.cc internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
common-utils.h
common.m4 gdb, gdbsupport: configure: factor out yes/no/auto value checking 2022-08-26 10:29:51 -04:00
compiler-type.m4
config.in Make GDBserver abort on internal error in development mode 2022-06-27 13:55:36 +01:00
configure gdbsupport: re-generate configure 2022-10-09 21:27:37 -04:00
configure.ac gdbsupport: Fix config.status dependency 2022-09-08 11:03:12 +00:00
create-version.sh
def-vector.h
default-init-alloc.h
eintr.h
enum-flags.h
environ.cc fix leak in gdb_environ 2022-11-27 21:08:24 +01:00
environ.h
errors.cc Fix Cygwin build after 02d04eac 2022-11-13 14:46:20 +00:00
errors.h Fix Cygwin build after 02d04eac 2022-11-13 14:46:20 +00:00
event-loop.cc internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
event-loop.h gdbsupport/event-loop: add a timeout parameter to gdb_do_one_event 2022-08-18 11:56:38 +02:00
event-pipe.cc
event-pipe.h
fileio.cc gdbsupport: move fileio_errno_to_host to fileio.{h,cc} and rename 2022-09-21 14:11:03 -04:00
fileio.h gdbsupport: move fileio_errno_to_host to fileio.{h,cc} and rename 2022-09-21 14:11:03 -04:00
filestuff.cc gdbsupport, gdb: add read_text_file_to_string, use it in linux_common_core_of_thread 2022-11-08 16:50:52 -05:00
filestuff.h gdbsupport, gdb: add read_text_file_to_string, use it in linux_common_core_of_thread 2022-11-08 16:50:52 -05:00
filtered-iterator.h
format.cc
format.h
forward-scope-exit.h
function-view.h gdbsupport: add wrapper around result_of and invoke_result 2022-08-30 14:43:26 -04:00
gdb_assert.h internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
gdb_binary_search.h
gdb_file.h
gdb_locale.h
gdb_obstack.cc
gdb_obstack.h
gdb_optional.h gdbsupport: fix gdb::optional compilation with C++11 && _GLIBCXX_DEBUG 2022-08-26 11:47:23 -04:00
gdb_proc_service.h
gdb_ref_ptr.h
gdb_regex.cc
gdb_regex.h
gdb_select.h
gdb_setjmp.h
gdb_signals.h
gdb_splay_tree.h
gdb_string_view.h
gdb_string_view.tcc
gdb_sys_time.h
gdb_tilde_expand.cc
gdb_tilde_expand.h
gdb_unique_ptr.h
gdb_unlinker.h
gdb_vecs.cc
gdb_vecs.h
gdb_wait.cc
gdb_wait.h
gdb-checked-static-cast.h gdbsupport: add checked_static_cast 2022-07-21 15:19:43 +01:00
gdb-dlfcn.cc
gdb-dlfcn.h
gdb-hashtab.cc
gdb-hashtab.h
gdb-safe-ctype.h
gdb-sigmask.h
gdb-xfree.h
hash_enum.h
host-defs.h
intrusive_list.h
invoke-result.h gdbsupport: add wrapper around result_of and invoke_result 2022-08-30 14:43:26 -04:00
iterator-range.h gdb: new $_inferior_thread_count convenience variable 2022-11-17 14:49:41 +00:00
job-control.cc
job-control.h
Makefile.am
Makefile.in gdbsupport: Fix config.status dependency 2022-09-08 11:03:12 +00:00
netstuff.cc
netstuff.h
new-op.cc
next-iterator.h
observable.h
offset-type.h
packed.h struct packed: Add fallback byte array implementation 2022-07-25 16:04:05 +01:00
parallel-for.h gdbsupport: add wrapper around result_of and invoke_result 2022-08-30 14:43:26 -04:00
pathstuff.cc gdbsupport: change path_join parameter to array_view<const char *> 2022-09-21 11:36:01 -04:00
pathstuff.h gdbsupport: change path_join parameter to array_view<const char *> 2022-09-21 11:36:01 -04:00
poison.h
preprocessor.h
print-utils.cc internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
print-utils.h
ptid.cc
ptid.h
ptrace.m4
range-chain.h Finalize each cooked index separately 2022-05-26 07:35:30 -06:00
README
refcounted-object.h
reference-to-pointer-iterator.h
rsp-low.cc
rsp-low.h
run-time-clock.cc
run-time-clock.h
safe-iterator.h
safe-strerror.cc
scope-exit.h
scoped_fd.h
scoped_ignore_signal.h
scoped_ignore_sigttou.h
scoped_mmap.cc
scoped_mmap.h
scoped_restore.h
search.cc
search.h
selftest.cc
selftest.h
selftest.m4
signals-state-save-restore.cc
signals-state-save-restore.h
signals.cc
symbol.h
tdesc.cc
tdesc.h
thread-pool.cc
thread-pool.h
traits.h
underlying.h
valid-expr.h
version.h
warning.m4
x86-xstate.h
xml-utils.cc
xml-utils.h

This is a helper library that is used by gdb and gdbserver.

To send patches, follow the gdb patch submission instructions in
../gdb/CONTRIBUTE.  For maintainers, see ../gdb/MAINTAINERS.