Issue 96512
Summary [ASAN] new-delete-type-mismatch on aligned operator new
Labels new issue
Assignees
Reporter thiagomacieira
    Simple test case:
```c++
#include <new>
int main()
{
    delete new (std::align_val_t(64)) char;
}
```
Produces:
```
=================================================================
==31626==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x509000000040 in thread T0:
  object passed to delete has wrong type:
  alignment of the allocated type:   64 bytes;
  alignment of the deallocated type: default-aligned.
    #0 0x5575d77192f8 in operator delete(void*) /home/abuild/rpmbuild/BUILD/llvm-18.1.6.src/projects/compiler-rt/lib/asan/asan_new_delete.cpp:143:3
 #1 0x5575d771aeb4 in main (/tmp/asan+0x10eeb4) (BuildId: 60e9703eb3f6670b2556a286db665665d9671536)
    #2 0x7ff8b962a1ef in __libc_start_call_main (/lib64/libc.so.6+0x2a1ef) (BuildId: a2c0942c27fb9483b47886a1b937337a797bbceb)
    #3 0x7ff8b962a2b8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x2a2b8) (BuildId: a2c0942c27fb9483b47886a1b937337a797bbceb)
    #4 0x5575d763d104 in _start /home/abuild/rpmbuild/BUILD/glibc-2.39/csu/../sysdeps/x86_64/start.S:115

0x509000000040 is located 0 bytes inside of 1-byte region [0x509000000040,0x509000000041)
allocated by thread T0 here:
    #0 0x5575d7718e7d in operator new(unsigned long, std::align_val_t) /home/abuild/rpmbuild/BUILD/llvm-18.1.6.src/projects/compiler-rt/lib/asan/asan_new_delete.cpp:98:3
 #1 0x5575d771ae9d in main (/tmp/asan+0x10ee9d) (BuildId: 60e9703eb3f6670b2556a286db665665d9671536)
    #2 0x7ff8b962a1ef in __libc_start_call_main (/lib64/libc.so.6+0x2a1ef) (BuildId: a2c0942c27fb9483b47886a1b937337a797bbceb)

SUMMARY: AddressSanitizer: new-delete-type-mismatch (/tmp/asan+0x10eeb4) (BuildId: 60e9703eb3f6670b2556a286db665665d9671536) in main
==31626==HINT: if you don't care about these errors you may set ASAN_OPTIONS=new_delete_type_mismatch=0
==31626==ABORTING
```

Reproduced with LLVM 18.1.6.

Matching GCC bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115619
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to