public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "thiago at kde dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug sanitizer/115619] New: [ASAN] new-delete-type-mismatch on aligned operator new
Date: Mon, 24 Jun 2024 16:29:49 +0000	[thread overview]
Message-ID: <bug-115619-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115619

            Bug ID: 115619
           Summary: [ASAN] new-delete-type-mismatch on aligned operator
                    new
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thiago at kde dot org
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
  Target Milestone: ---

Simple test case:

#include <new>
int main()
{
    delete new (std::align_val_t(64)) char;
}

Produces:

=================================================================
==31603==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x509000000040 in
thread T0:
  object passed to delete has wrong type:
  size of the allocated type:   1 bytes;
  size of the deallocated type: 1 bytes.
  alignment of the allocated type:   64 bytes;
  alignment of the deallocated type: default-aligned.
    #0 0x7f8abfefd0d8 in operator delete(void*, unsigned long)
(/lib64/libasan.so.8+0xfd0d8) (BuildId:
1827a4c72065a9f25ba519b25166029eebbf519f)
    #1 0x40118a in main (/tmp/asan+0x40118a) (BuildId:
8bfb14839297ab61e6a8de28f913cc801a1f7cd7)
    #2 0x7f8abf62a1ef in __libc_start_call_main (/lib64/libc.so.6+0x2a1ef)
(BuildId: a2c0942c27fb9483b47886a1b937337a797bbceb)
    #3 0x7f8abf62a2b8 in __libc_start_main_alias_2 (/lib64/libc.so.6+0x2a2b8)
(BuildId: a2c0942c27fb9483b47886a1b937337a797bbceb)
    #4 0x401094 in _start ../sysdeps/x86_64/start.S:115

0x509000000040 is located 0 bytes inside of 1-byte region
[0x509000000040,0x509000000041)
allocated by thread T0 here:
    #0 0x7f8abfefc708 in operator new(unsigned long, std::align_val_t)
(/lib64/libasan.so.8+0xfc708) (BuildId:
1827a4c72065a9f25ba519b25166029eebbf519f)
    #1 0x401178 in main (/tmp/asan+0x401178) (BuildId:
8bfb14839297ab61e6a8de28f913cc801a1f7cd7)
    #2 0x7f8abf62a1ef in __libc_start_call_main (/lib64/libc.so.6+0x2a1ef)
(BuildId: a2c0942c27fb9483b47886a1b937337a797bbceb)

SUMMARY: AddressSanitizer: new-delete-type-mismatch
(/lib64/libasan.so.8+0xfd0d8) (BuildId:
1827a4c72065a9f25ba519b25166029eebbf519f) in operator delete(void*, unsigned
long)
==31603==HINT: if you don't care about these errors you may set
ASAN_OPTIONS=new_delete_type_mismatch=0
==31603==ABORTING

Reproduced with GCC 13, 14 and with Clang 18.

             reply	other threads:[~2024-06-24 16:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24 16:29 thiago at kde dot org [this message]
2024-06-24 16:34 ` [Bug sanitizer/115619] " thiago at kde dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-115619-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).