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 fortran/110677] UBSAN error: load of value 1818451807, which is not a valid value for type 'expr_t' when compiling pr49213.f90
Date: Tue, 15 Aug 2023 15:15:09 +0000	[thread overview]
Message-ID: <bug-110677-4-ysWn6uk0Dr@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110677-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>:

https://gcc.gnu.org/g:84e122c34834d9dea189c10fe0bf60c4d1a99fae

commit r14-3224-g84e122c34834d9dea189c10fe0bf60c4d1a99fae
Author: Martin Jambor <mjambor@suse.cz>
Date:   Tue Aug 15 17:13:44 2023 +0200

    Fortran: Avoid accessing gfc_charlen when not looking at BT_CHARACTER (PR
110677)

    This patch addresses an issue uncovered by the undefined behavior
    sanitizer.  In function resolve_structure_cons in resolve.cc there is
    a test starting with:

          if (cons->expr->ts.type == BT_CHARACTER && comp->ts.u.cl
              && comp->ts.u.cl->length
              && comp->ts.u.cl->length->expr_type == EXPR_CONSTANT

    and UBSAN complained of loads from comp->ts.u.cl->length->expr_type of
    integer value 1818451807 which is outside of the value range expr_t
    enum.  If I understand the code correctly it the entire load was
    unwanted because comp->ts.type in those cases is BT_CLASS and not
    BT_CHARACTER.  This patch simply adds a check to make sure it is only
    accessed in those cases.

    During review, Harald Anlauf noticed that length types also need to be
    checked and so I added also checks that he suggested to the condition.

    Co-authored-by: Harald Anlauf <anlauf@gmx.de>

    gcc/fortran/ChangeLog:

    2023-08-14  Martin Jambor  <mjambor@suse.cz>

            PR fortran/110677
            * resolve.cc (resolve_structure_cons): Check comp->ts is character
            type before accessing stuff through comp->ts.u.cl.

  parent reply	other threads:[~2023-08-15 15:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-15 19:54 [Bug fortran/110677] New: " jamborm at gcc dot gnu.org
2023-07-22 16:57 ` [Bug fortran/110677] " jamborm at gcc dot gnu.org
2023-08-14 17:41 ` jamborm at gcc dot gnu.org
2023-08-15 15:15 ` cvs-commit at gcc dot gnu.org [this message]
2023-08-15 15:19 ` jamborm 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-110677-4-ysWn6uk0Dr@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).