From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B43D2385841E; Tue, 27 Jun 2023 09:56:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B43D2385841E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687859814; bh=s10cp1Ql516heUykmYkUFKzkhcCyiaFT3Uo/nl+udl8=; h=From:To:Subject:Date:From; b=nUe1AFD65/CFB1ACkPmLsfJvM9tkPdVDcSsrCAKDf/ZlB8+gIKJOPO52vKyDbM3q9 tkJioDXMxPFOpwFP2A4OwKC0cHleOtY3NvNnvwZ2bwH05gX0KpoH4RgaG5zKQPTOgz lv+sikQEdW65joOzkwilIKKhy3k711hy3G1RPaFY= From: "jamborm at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/110433] New: ASAN reports mismatching new/delete when compiling analyzer testcases Date: Tue, 27 Jun 2023 09:56:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jamborm at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dmalcolm at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc blocked target_milestone cf_gcchost cf_gcctarget Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110433 Bug ID: 110433 Summary: ASAN reports mismatching new/delete when compiling analyzer testcases Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: jamborm at gcc dot gnu.org CC: dmalcolm at gcc dot gnu.org Blocks: 86656 Target Milestone: --- Host: x86_64-linux Target: x86_64-linux With a bootstrapped compiler configured with --with-build-config=3Dbootstrap-asan I get errors about new/delete mismatching types when compiling testcases: - gcc.dg/analyzer/out-of-bounds-diagram-13.c - gcc.dg/analyzer/out-of-bounds-diagram-15.c - gcc.dg/analyzer/out-of-bounds-diagram-4.c - gcc.dg/analyzer/out-of-bounds-diagram-5-ascii.c - gcc.dg/analyzer/out-of-bounds-diagram-5-unicode.c and - gcc.dg/analyzer/out-of-bounds-diagram-7.c The errors all look like: Executing on host: /home/worker/buildworker/tiber-gcc-asan/objdir/gcc/xgcc -B/home/worker/buildworker/tiber-gcc-asan/objdir/gcc/=20 /home/worker/buildworker/tiber-gcc-asan/build/gcc/testsuite/gcc.dg/analyzer= /out-of-bounds-diagram-13.c -fdiagnostics-plain-output -fanalyzer -Wanalyzer-too-complex -fanalyzer-call-summaries -fdiagnostics-text-art-charset=3Dunicode -S -o out-of-bounds-diagram-13.s (timeout =3D 300) spawn -ignore SIGHUP /home/worker/buildworker/tiber-gcc-asan/objdir/gcc/xgcc -B/home/worker/buildworker/tiber-gcc-asan/objdir/gcc/ /home/worker/buildworker/tiber-gcc-asan/build/gcc/testsuite/gcc.dg/analyzer= /out-of-bounds-diagram-13.c -fdiagnostics-plain-output -fanalyzer -Wanalyzer-too-complex -fanalyzer-call-summaries -fdiagnostics-text-art-charset=3Dunicode -S -o out-of-bounds-diagram-13.s /home/worker/buildworker/tiber-gcc-asan/build/gcc/testsuite/gcc.dg/analyzer= /out-of-bounds-diagram-13.c: In function 'test_non_ascii': /home/worker/buildworker/tiber-gcc-asan/build/gcc/testsuite/gcc.dg/analyzer= /out-of-bounds-diagram-13.c:9:3: warning: stack-based buffer overflow [CWE-121] [-Wanalyzer-out-of-bounds] /home/worker/buildworker/tiber-gcc-asan/build/gcc/testsuite/gcc.dg/analyzer= /out-of-bounds-diagram-13.c:8:8: note: (1) capacity: 9 bytes /home/worker/buildworker/tiber-gcc-asan/build/gcc/testsuite/gcc.dg/analyzer= /out-of-bounds-diagram-13.c:9:3: note: (2) out-of-bounds write at byte 9 but 'buf' ends at byte 9 /home/worker/buildworker/tiber-gcc-asan/build/gcc/testsuite/gcc.dg/analyzer= /out-of-bounds-diagram-13.c:9:3: note: write of 1 byte to beyond the end of 'buf' /home/worker/buildworker/tiber-gcc-asan/build/gcc/testsuite/gcc.dg/analyzer= /out-of-bounds-diagram-13.c:9:3: note: valid subscripts for 'buf' are '[0]' to '[8]' =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D58507=3D=3DERROR: AddressSanitizer: new-delete-type-mismatch on 0x50d= 000000a00 in thread T0: object passed to delete has wrong type: size of the allocated type: 136 bytes; size of the deallocated type: 104 bytes. #0 0x83eba8 in operator delete(void*, unsigned long) /home/worker/buildworker/tiber-gcc-asan/build/libsanitizer/asan/asan_new_de= lete.cpp:164 #1 0x51e6e45 in std::default_delete::operator()(ana::svalue_spati= al_item*) const /home/worker/buildworker/tiber-gcc-asan/objdir/prev-x86_64-pc-linux-gnu/lib= stdc++-v3/include/bits/unique_ptr.h:99 #2 0x51e6e45 in std::unique_ptr >::~unique_ptr() /home/worker/buildworker/tiber-gcc-asan/objdir/prev-x86_64-pc-linux-gnu/lib= stdc++-v3/include/bits/unique_ptr.h:404 #3 0x51e6e45 in ana::access_diagram_impl::~access_diagram_impl() /home/worker/buildworker/tiber-gcc-asan/build/gcc/analyzer/access-diagram.c= c:1728 #4 0x51e703c in ana::access_diagram_impl::~access_diagram_impl() /home/worker/buildworker/tiber-gcc-asan/build/gcc/analyzer/access-diagram.c= c:1728 #5 0x4e97142 in std::default_delete::operator()(text_art::widget*) const /home/worker/buildworker/tiber-gcc-asan/objdir/prev-x86_64-pc-linux-gnu/lib= stdc++-v3/include/bits/unique_ptr.h:99 #6 0x4e97142 in std::unique_ptr >::~unique_ptr() /home/worker/buildworker/tiber-gcc-asan/objdir/prev-x86_64-pc-linux-gnu/lib= stdc++-v3/include/bits/unique_ptr.h:404 -- =3D=3D58507=3D=3DHINT: if you don't care about these errors you may set ASAN_OPTIONS=3Dnew_delete_type_mismatch=3D0 =3D=3D58507=3D=3DABORTING compiler exited with status 1 PASS: gcc.dg/analyzer/out-of-bounds-diagram-13.c (test for warnings, line = 9) FAIL: gcc.dg/analyzer/out-of-bounds-diagram-13.c at line 10 (test for warnings, line 9) FAIL: gcc.dg/analyzer/out-of-bounds-diagram-13.c expected multiline pattern lines 17-42 FAIL: gcc.dg/analyzer/out-of-bounds-diagram-13.c 2 blank line(s) in output FAIL: gcc.dg/analyzer/out-of-bounds-diagram-13.c (test for excess errors) Excess errors: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D58507=3D=3DERROR: AddressSanitizer: new-delete-type-mismatch on 0x50d= 000000a00 in thread T0: object passed to delete has wrong type: size of the allocated type: 136 bytes; size of the deallocated type: 104 bytes. #0 0x83eba8 in operator delete(void*, unsigned long) /home/worker/buildworker/tiber-gcc-asan/build/libsanitizer/asan/asan_new_de= lete.cpp:164 #1 0x51e6e45 in std::default_delete::operator()(ana::svalue_spati= al_item*) const /home/worker/buildworker/tiber-gcc-asan/objdir/prev-x86_64-pc-linux-gnu/lib= stdc++-v3/include/bits/unique_ptr.h:99 #2 0x51e6e45 in std::unique_ptr >::~unique_ptr() /home/worker/buildworker/tiber-gcc-asan/objdir/prev-x86_64-pc-linux-gnu/lib= stdc++-v3/include/bits/unique_ptr.h:404 #3 0x51e6e45 in ana::access_diagram_impl::~access_diagram_impl() /home/worker/buildworker/tiber-gcc-asan/build/gcc/analyzer/access-diagram.c= c:1728 #4 0x51e703c in ana::access_diagram_impl::~access_diagram_impl() /home/worker/buildworker/tiber-gcc-asan/build/gcc/analyzer/access-diagram.c= c:1728 #5 0x4e97142 in std::default_delete::operator()(text_art::widget*) const /home/worker/buildworker/tiber-gcc-asan/objdir/prev-x86_64-pc-linux-gnu/lib= stdc++-v3/include/bits/unique_ptr.h:99 #6 0x4e97142 in std::unique_ptr >::~unique_ptr() /home/worker/buildworker/tiber-gcc-asan/objdir/prev-x86_64-pc-linux-gnu/lib= stdc++-v3/include/bits/unique_ptr.h:404 I'll see if I can provide longer stack traces (in reasonable time). Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D86656 [Bug 86656] [meta-bug] Issues found with -fsanitize=3Daddress=