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 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
.gitattributes gdb, gdbserver, gdbsupport: add .gitattributes files 2020-03-05 15:59:22 +01:00
acinclude.m4 gdb: don't use -Wmissing-prototypes with g++ 2022-01-13 10:25:45 +00:00
aclocal.m4 gdb: use AC_PROG_CC_STDC instead of AM_PROG_CC_STDC 2020-10-31 08:30:57 -04:00
agent.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
agent.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
alt-stack.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
array-view.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
ax.def Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
block-signals.h [gdb] Block SIGTERM in worker threads 2022-06-30 13:31:06 +02:00
break-common.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
btrace-common.cc internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
btrace-common.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
buffer.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
buffer.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
buildargv.h Move gdb_argv to gdbsupport 2022-01-18 10:14:42 -07:00
byte-vector.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
ChangeLog-2020-2021 gdb: move remaining ChangeLogs to legacy files 2021-07-26 12:20:33 +01:00
check-defines.el Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
cleanups.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
cleanups.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-debug.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-debug.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
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 Specialize std::hash for gdb_exception 2022-04-12 09:31:16 -06:00
common-gdbthread.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-inferior.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-inferior.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-regcache.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-regcache.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-types.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-utils.cc internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
common-utils.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common.m4 gdb, gdbsupport: configure: factor out yes/no/auto value checking 2022-08-26 10:29:51 -04:00
compiler-type.m4 gdb: don't use -Wmissing-prototypes with g++ 2022-01-13 10:25:45 +00:00
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 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
def-vector.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
default-init-alloc.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
eintr.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
enum-flags.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
environ.cc fix leak in gdb_environ 2022-11-27 21:08:24 +01:00
environ.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
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 Fix typo in last change. 2022-03-03 13:06:50 -08:00
event-pipe.h Avoid conflict with gnulib open/close macros. 2022-03-03 11:21:36 -08:00
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 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
format.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
format.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
forward-scope-exit.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
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 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_file.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_locale.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_obstack.cc Move gdb obstack code to gdbsupport 2022-01-18 10:14:42 -07:00
gdb_obstack.h Move gdb obstack code to gdbsupport 2022-01-18 10:14:42 -07:00
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 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_ref_ptr.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_regex.cc gdbsupport/gdb_regex.cc: replace defs.h include with common-defs.h 2022-01-20 22:58:21 -05:00
gdb_regex.h Move gdb_regex to gdbsupport 2022-01-18 10:14:43 -07:00
gdb_select.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_setjmp.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_signals.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_splay_tree.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_string_view.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_string_view.tcc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_sys_time.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_tilde_expand.cc gdb: use gdb_tilde_expand instead of gdb_tilde_expand_up in source_script_with_search 2022-04-18 15:48:03 -04:00
gdb_tilde_expand.h gdb: use gdb_tilde_expand instead of gdb_tilde_expand_up in source_script_with_search 2022-04-18 15:48:03 -04:00
gdb_unique_ptr.h gdb: add operator+= and operator+ overload for std::string 2022-02-25 17:50:22 +00:00
gdb_unlinker.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_vecs.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_vecs.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_wait.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_wait.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb-checked-static-cast.h gdbsupport: add checked_static_cast 2022-07-21 15:19:43 +01:00
gdb-dlfcn.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb-dlfcn.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb-hashtab.cc Introduce gdb-hashtab module in gdbsupport 2022-01-18 10:14:43 -07:00
gdb-hashtab.h Introduce gdb-hashtab module in gdbsupport 2022-01-18 10:14:43 -07:00
gdb-safe-ctype.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb-sigmask.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb-xfree.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
hash_enum.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
host-defs.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
intrusive_list.h Make intrusive_list_node's next/prev private 2022-04-13 10:24:38 +01:00
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 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
job-control.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
Makefile.am gdbsupport: Add an event-pipe class. 2022-02-22 11:22:14 -08:00
Makefile.in gdbsupport: Fix config.status dependency 2022-09-08 11:03:12 +00:00
netstuff.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
netstuff.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
new-op.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
next-iterator.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
observable.h Move non-dependent gdb::observers::observable::visit_state outside template 2022-05-10 13:40:57 +01:00
offset-type.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
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 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
preprocessor.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
print-utils.cc internal_error: remove need to pass __FILE__/__LINE__ 2022-10-19 15:32:36 +01:00
print-utils.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
ptid.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
ptid.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
ptrace.m4 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
range-chain.h Finalize each cooked index separately 2022-05-26 07:35:30 -06:00
README
refcounted-object.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
reference-to-pointer-iterator.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
rsp-low.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
rsp-low.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
run-time-clock.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
run-time-clock.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
safe-iterator.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
safe-strerror.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
scope-exit.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
scoped_fd.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
scoped_ignore_signal.h gdb: don't pass nullptr to sigwait 2022-01-04 10:28:19 +00:00
scoped_ignore_sigttou.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
scoped_mmap.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
scoped_mmap.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
scoped_restore.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
search.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
search.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
selftest.cc gdbsupport/selftest: Allow lazy registration 2022-04-19 09:12:42 +01:00
selftest.h gdbsupport/selftest: Allow lazy registration 2022-04-19 09:12:42 +01:00
selftest.m4 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
signals-state-save-restore.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
signals-state-save-restore.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
signals.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
symbol.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
tdesc.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
tdesc.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
thread-pool.cc Fix --disable-threading build 2022-05-10 08:15:40 -06:00
thread-pool.h Fix --disable-threading build 2022-05-10 08:15:40 -06:00
traits.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
underlying.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
valid-expr.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
version.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
warning.m4 gdb: don't use -Wmissing-prototypes with g++ 2022-01-13 10:25:45 +00:00
x86-xstate.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
xml-utils.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
xml-utils.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00

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.