This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/5] Poison non-POD memset & non-trivially-copyable memcpy/memmove
- From: Pedro Alves <palves at redhat dot com>
- To: Simon Marchi <simon dot marchi at polymtl dot ca>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 17 May 2017 12:35:55 +0100
- Subject: Re: [PATCH 1/5] Poison non-POD memset & non-trivially-copyable memcpy/memmove
- Authentication-results: sourceware.org; auth=none
- References: <1492050475-9238-1-git-send-email-palves@redhat.com> <1492050475-9238-2-git-send-email-palves@redhat.com> <b19b285127612eb7fbcd45e0ae41d499@polymtl.ca> <9ee5551a7999a72a0040f15e6e5410a1@polymtl.ca> <ed2f15b6-8920-2124-8df4-135a4ce9a1d1@redhat.com> <9c15c7f2d50cdb53f39719dba3eb589e@polymtl.ca>
On 04/30/2017 02:51 AM, Simon Marchi wrote:
> I think it would be a good guideline to use new/delete for types that
> have some C++-related stuff in them, even if it's not technically
> necessary.
>
> Note that this won't be bulletproof also because at many places xfree is
> used on a void pointer, so we don't know what we're really free'ing. In
> some other cases, objects are freed using a pointer to their "C base
> class".
Yeah. Still, better than nothing.
BTW, GCC ran into similar issues almost at the same time
we started discussing this, and I've been discussing
with the GCC folks about a new GCC warning that flags invalid
memcpy/memset misuses. Martin Sebor has been working on a patch
and it's getting close to be merged, AFAICT.
See:
https://gcc.gnu.org/ml/gcc-patches/2017-04/msg01527.html
First version of the GCC patch here:
https://gcc.gnu.org/ml/gcc-patches/2017-04/msg01571.html
Discussion crossed month boundary here:
https://gcc.gnu.org/ml/gcc-patches/2017-05/msg00925.html
Latest patch is here:
https://gcc.gnu.org/ml/gcc-patches/2017-05/msg00976.html
I won't be a full replacement since we'll still want our
poisoning for other functions (xmalloc, xfree, etc.). And
then there's current/older gccs. But still, pretty neat, IMO.
Thanks,
Pedro Alves