Bug 467441 - Add mismatched detection to C++ 14 sized delete
Summary: Add mismatched detection to C++ 14 sized delete
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.21 GIT
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on: 433857
Blocks:
  Show dependency treegraph
 
Reported: 2023-03-16 11:01 UTC by Paul Floyd
Modified: 2023-09-11 09:54 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Floyd 2023-03-16 11:01:26 UTC
+++ This bug was initially created as a clone of Bug #433857 +++
Comment 1 Paul Floyd 2023-03-16 11:03:21 UTC
Last comment in https://bugs.kde.org/show_bug.cgi?id=433857 shoudl really be here

ASAN example

Here ASAN is assuming use of new delete expressions whilst I was making raw calls to the operators.

paulf> ./new_delete_mismatch_size.asan
=================================================================
==1505==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x603000000040 in thread T0:
  object passed to delete has wrong type:
  size of the allocated type:   32 bytes;
  size of the deallocated type: 33 bytes.
    #0 0x2b9452 in operator delete(void*, unsigned long) /usr/src/contrib/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:164:3
    #1 0x2bb021 in main /usr/home/paulf/scratch/valgrind/memcheck/tests/new_delete_mismatch_size.cpp:18:5
    #2 0x23613f in _start /usr/src/lib/csu/amd64/crt1_c.c:75:7
    #3 0x8002e0007  (<unknown module>)

So far I have

==7503== Mismatched new/delete with size 33 
==7503==    at 0x484F133: operator delete(void*, unsigned long) (vg_replace_malloc.c:1036)
==7503==    by 0x201AF1: main (new_delete_mismatch_size.cpp:18)
==7503==  Address 0x55b4040 is 0 bytes inside a block of size 32 alloc'd
==7503==    at 0x484D0D4: operator new(unsigned long) (vg_replace_malloc.c:487)
==7503==    by 0x201AE0: main (new_delete_mismatch_size.cpp:17)
Comment 2 Paul Floyd 2023-09-11 09:54:23 UTC
Fixed.