public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/94325] [8/9 Regression] UBSAN: "invalid vptr" false positive for virtual inheritance with -fno-sanitize-recover=all Date: Wed, 16 Sep 2020 19:20:06 +0000 [thread overview] Message-ID: <bug-94325-4-SqBUJeLwmy@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-94325-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94325 --- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-9 branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:175f052446556d32e887e1658a5a92c3c2f3a6f5 commit r9-8875-g175f052446556d32e887e1658a5a92c3c2f3a6f5 Author: Jakub Jelinek <jakub@redhat.com> Date: Wed Apr 8 15:30:16 2020 +0200 c++: Further fix for -fsanitize=vptr [PR94325] For -fsanitize=vptr, we insert a NULL store into the vptr instead of just adding a CLOBBER of this. build_clobber_this makes the CLOBBER conditional on in_charge (implicit) parameter whenever CLASSTYPE_VBASECLASSES, but when adding this conditionalization to the -fsanitize=vptr code in PR87095, I wanted it to catch some more cases when the class has CLASSTYPE_VBASECLASSES, but the vptr is still not shared with something else, otherwise the sanitization would be less effective. The following testcase shows that the chosen test that CLASSTYPE_PRIMARY_BINFO is non-NULL and has BINFO_VIRTUAL_P set wasn't sufficient, the D class has still sizeof(D) == sizeof(void*) and thus contains just a single vptr, but while in B::~B() this results in the vptr not being cleared, in C::~C() this condition isn't true, as CLASSTYPE_PRIMARY_BINFO in that case is B and is not BINFO_VIRTUAL_P, so it clears the vptr, but the D::~D() dtor after invoking C::~C() invokes A::~A() with an already cleared vptr, which is then reported. The following patch is just a shot in the dark, keep looking through CLASSTYPE_PRIMARY_BINFO until we find BINFO_VIRTUAL_P, but it works on the existing testcase as well as this new one. 2020-04-08 Jakub Jelinek <jakub@redhat.com> PR c++/94325 * decl.c (begin_destructor_body): For CLASSTYPE_VBASECLASSES class dtors, if CLASSTYPE_PRIMARY_BINFO is non-NULL, but not BINFO_VIRTUAL_P, look at CLASSTYPE_PRIMARY_BINFO of its BINFO_TYPE if it is not BINFO_VIRTUAL_P, and so on. * g++.dg/ubsan/vptr-15.C: New test. (cherry picked from commit 4cf6b06cb5b02c053738e2975e3b7a4b3c577401)
next prev parent reply other threads:[~2020-09-16 19:20 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-25 12:56 [Bug c++/94325] New: [UBSAN] " jaroslaw.melzer.gcc at gmail dot com 2020-03-25 13:09 ` [Bug sanitizer/94325] " marxin at gcc dot gnu.org 2020-03-25 13:58 ` [Bug sanitizer/94325] [8/9/10 Regression] UBSAN: " marxin at gcc dot gnu.org 2020-04-01 9:00 ` rguenth at gcc dot gnu.org 2020-04-06 11:27 ` jakub at gcc dot gnu.org 2020-04-06 11:41 ` jakub at gcc dot gnu.org 2020-04-08 13:31 ` cvs-commit at gcc dot gnu.org 2020-04-08 13:33 ` [Bug sanitizer/94325] [8/9 " jakub at gcc dot gnu.org 2020-09-16 19:20 ` cvs-commit at gcc dot gnu.org [this message] 2020-09-17 17:22 ` jakub at gcc dot gnu.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-94325-4-SqBUJeLwmy@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: linkBe 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).