[PATCH 1/5] Poison non-POD memset & non-trivially-copyable memcpy/memmove
Simon Marchi
simon.marchi@polymtl.ca
Wed May 17 13:11:00 GMT 2017
On 2017-05-17 07:35, Pedro Alves wrote:
> 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 for the info!
I have a branch in progress about poisoning XNEW and friends:
https://github.com/simark/binutils-gdb/commits/poison-xnew
I won't have time to look at it until at least next week, if anybody
wants to pick it up, they are free to do so.
Simon
More information about the Gdb-patches
mailing list