public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "matt at use dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug bootstrap/55644] maybe-uninitialized false positive
Date: Fri, 01 Mar 2013 23:35:00 -0000	[thread overview]
Message-ID: <bug-55644-4-oamezZEMch@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55644-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55644

Matt Hargett <matt at use dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|bootstrap-lto fails on      |maybe-uninitialized false
                   |current trunk (with and     |positive
                   |without profiledbootstrap)  |

--- Comment #11 from Matt Hargett <matt at use dot net> 2013-03-01 23:34:53 UTC ---
The current false positives emitted:

mhargett@chert:/work/mhargett/gcc-trunk-lto-O3-debug/gcc$
/work/mhargett/gcc-trunk-lto-O3-debug/./prev-gcc/xg++
-B/work/mhargett/gcc-trunk-lto-O3-debug/./prev-gcc/
-B/u/mhargett/x86_64-unknown-linux-gnu/bin/ -nostdinc++
-B/work/mhargett/gcc-trunk-lto-O3-debug/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs
-B/work/mhargett/gcc-trunk-lto-O3-debug/prev-x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs
-I/work/mhargett/gcc-trunk-lto-O3-debug/prev-x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu
-I/work/mhargett/gcc-trunk-lto-O3-debug/prev-x86_64-unknown-linux-gnu/libstdc++-v3/include
-I/work/mhargett/gcc-trunk/libstdc++-v3/libsupc++
-L/work/mhargett/gcc-trunk-lto-O3-debug/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs
-L/work/mhargett/gcc-trunk-lto-O3-debug/prev-x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs
  -O3 -g -flto=jobserver -flto-partition=none -frandom-seed=1 -gtoggle -DIN_GCC
  -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall
-Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common
 -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc  gcov-dump.o                
libcommon.a ../libcpp/libcpp.a   ../libbacktrace/.libs/libbacktrace.a
../libiberty/libiberty.a ../libdecnumber/libdecnumber.a  -o gcov-dump
../../gcc-trunk/libbacktrace/elf.c: In function 'elf_add':
../../gcc-trunk/libbacktrace/mmapio.c:98:14: error: 'ehdr_view.len' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
   if (munmap (const_cast.v, view->len) < 0)
              ^
../../gcc-trunk/libbacktrace/elf.c:476:25: note: 'ehdr_view.len' was declared
here
   struct backtrace_view ehdr_view;
                         ^
../../gcc-trunk/libbacktrace/mmapio.c:98:14: error: 'ehdr_view.base' may be
used uninitialized in this function [-Werror=maybe-uninitialized]
   if (munmap (const_cast.v, view->len) < 0)
              ^
../../gcc-trunk/libbacktrace/elf.c:476:25: note: 'ehdr_view.base' was declared
here
   struct backtrace_view ehdr_view;
                         ^
../../gcc-trunk/libbacktrace/elf.c:516:10: error: 'ehdr_view.data' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
   memcpy (&ehdr, ehdr_view.data, sizeof ehdr);
          ^
../../gcc-trunk/libbacktrace/elf.c:476:25: note: 'ehdr_view.data' was declared
here
   struct backtrace_view ehdr_view;
                         ^


which is a false positive, because

ehdr_view's fields are correctly initialized via a call from elf_add() to
backtrace_get_view()
  view->data = (char *) map + inpage;
  view->base = map;
  view->len = size;

if the mmap() earlier in the backtrace_get_view() didn't fail, view is
initialized and the backtrace_get_view() returns 1. if that mmap() fails, view
remains uninitialized and backtrace_get_view() returns 0.

elf_add()'s invocation checks the return value of backtrace_get_view(). in the
0 (failure) case, backtrace_release_view() is never invoked:
  if (!backtrace_get_view (state, descriptor, 0, sizeof ehdr, error_callback,
                           data, &ehdr_view))
    goto fail;

since backtrace_release_view() is never called in the case where the fields are
uninitialized, the warning is a false positive. while it occurs here with the
confluence of several optimizations, it looks like the same problem would
happen in a contrived single-file case.

attached are the temp files for the module the generated this false positive.


  parent reply	other threads:[~2013-03-01 23:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-10 22:09 [Bug bootstrap/55644] New: profiledbootstrap fails on current trunk matt at use dot net
2012-12-10 22:19 ` [Bug bootstrap/55644] bootstrap-lto fails on current trunk (with and without profiledbootstrap) matt at use dot net
2012-12-11 10:07 ` rguenth at gcc dot gnu.org
2012-12-11 10:54 ` rguenth at gcc dot gnu.org
2012-12-11 13:57 ` hjl.tools at gmail dot com
2013-02-06  1:23 ` matt at use dot net
2013-02-06  9:55 ` rguenth at gcc dot gnu.org
2013-02-14 18:01 ` matt at use dot net
2013-02-14 18:47 ` hjl.tools at gmail dot com
2013-02-15  9:42 ` rguenth at gcc dot gnu.org
2013-03-01 23:12 ` matt at use dot net
2013-03-01 23:35 ` matt at use dot net [this message]
2013-03-01 23:39 ` [Bug middle-end/55644] maybe-uninitialized false positive due to incorrect flow analysis when gotos are present matt at use dot net
2013-03-04  5:52 ` d.g.gorbachev at gmail dot com
2021-04-12 20:12 ` msebor 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-55644-4-oamezZEMch@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).