public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/98692] New: Unitialized Values reported only with -Os
@ 2021-01-14 21:11 nick.child at ibm dot com
  2021-01-14 21:11 ` [Bug rtl-optimization/98692] " nick.child at ibm dot com
                   ` (23 more replies)
  0 siblings, 24 replies; 25+ messages in thread
From: nick.child at ibm dot com @ 2021-01-14 21:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98692
           Summary: Unitialized Values reported only with -Os
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nick.child at ibm dot com
  Target Milestone: ---
              Host: powerpcle-*-linux-gnu*
            Target: powerpcle-*-linux-gnu*
             Build: powerpcle-*-linux-gnu*

Created attachment 49970
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49970&action=edit
Preprocesssed File

Hello all,

This is my first go at something like this so I apologize for any cringes now.
Recently, I implemented memory checks into our CI using valgrind. Everything
works fine on x86 with the same commands but gives issues when running on
POWER. Specifically, only when using the `-Os` size optimizer flag. Things like
`O2` and `O3` don't bring about any errors. While the code runs fine, these
valgrind errors are a bit alarming. I have run into the issue using the
following compiler versions and OS's:
    gcc version 9.3.1 20200408 (Red Hat 9.3.1-2)
    gcc version 10.2.1 20200723 (Red Hat 10.2.1-1)
    gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)

The errors revolve around an conditional jump on unitialized variables. I am
thinking it is a stack allocation issue. I have tried to narrow down my issue
to as simple a program as possible (attached). 
I then build using:
   $ gcc -Os issue.c -o issue
Compilation works and binary executes normally but valgrind complains with:
   $ valgrind ./issue

This could very well be a valgrind mistake, with too many things being
optimized off of the executable for valgrind to accurately keep track of
memory.

Here is the output from valgrind:

==3557285== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==3557285== Command: leak
==3557285==
==3557285== Conditional jump or move depends on uninitialised value(s)
==3557285==    at 0x416E9B8: __vfprintf_internal (vfprintf-internal.c:1332)
==3557285==    by 0x415E33B: printf@@GLIBC_2.17 (printf.c:33)
==3557285==    by 0x100005D3: main (in /home/jenkins/testPlace/test2/leak)
==3557285==
==3557285== Use of uninitialised value of size 8
==3557285==    at 0x40A14DC: strchrnul (vg_replace_strmem.c:1394)
==3557285==    by 0x416E9D3: __find_specmb (printf-parse.h:111)
==3557285==    by 0x416E9D3: __vfprintf_internal (vfprintf-internal.c:1365)
==3557285==    by 0x415E33B: printf@@GLIBC_2.17 (printf.c:33)
==3557285==    by 0x100005D3: main (in /home/jenkins/testPlace/test2/leak)
==3557285==
==3557285== Use of uninitialised value of size 8
==3557285==    at 0x40A14F0: strchrnul (vg_replace_strmem.c:1394)
==3557285==    by 0x416E9D3: __find_specmb (printf-parse.h:111)
==3557285==    by 0x416E9D3: __vfprintf_internal (vfprintf-internal.c:1365)
==3557285==    by 0x415E33B: printf@@GLIBC_2.17 (printf.c:33)
==3557285==    by 0x100005D3: main (in /home/jenkins/testPlace/test2/leak)
==3557285==
==3557285== Conditional jump or move depends on uninitialised value(s)
==3557285==    at 0x418BABC: _IO_file_xsputn@@GLIBC_2.17 (fileops.c:1204)
==3557285==    by 0x416EA33: __vfprintf_internal (vfprintf-internal.c:1373)
==3557285==    by 0x415E33B: printf@@GLIBC_2.17 (printf.c:33)
==3557285==    by 0x100005D3: main (in /home/jenkins/testPlace/test2/leak)
==3557285==
==3557285== Conditional jump or move depends on uninitialised value(s)
==3557285==    at 0x418BC94: _IO_new_file_xsputn (fileops.c:1253)
==3557285==    by 0x418BC94: _IO_file_xsputn@@GLIBC_2.17 (fileops.c:1197)
==3557285==    by 0x416EA33: __vfprintf_internal (vfprintf-internal.c:1373)
==3557285==    by 0x415E33B: printf@@GLIBC_2.17 (printf.c:33)
==3557285==    by 0x100005D3: main (in /home/jenkins/testPlace/test2/leak)
==3557285==
...
...
...
==3558101==
==3558101== HEAP SUMMARY:
==3558101==     in use at exit: 0 bytes in 0 blocks
==3558101==   total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated
==3558101==
==3558101== All heap blocks were freed -- no leaks are possible
==3558101==
==3558101== Use --track-origins=yes to see where uninitialised values come from
==3558101== For lists of detected and suppressed errors, rerun with: -s
==3558101== ERROR SUMMARY: 44 errors from 31 contexts (suppressed: 0 from 0)

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2021-02-10 16:34 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14 21:11 [Bug rtl-optimization/98692] New: Unitialized Values reported only with -Os nick.child at ibm dot com
2021-01-14 21:11 ` [Bug rtl-optimization/98692] " nick.child at ibm dot com
2021-01-15  8:58 ` marxin at gcc dot gnu.org
2021-01-15  9:24 ` marxin at gcc dot gnu.org
2021-01-15 23:58 ` segher at gcc dot gnu.org
2021-01-16  0:01 ` segher at gcc dot gnu.org
2021-01-18  8:05 ` marxin at gcc dot gnu.org
2021-01-18 15:11 ` acsawdey at gcc dot gnu.org
2021-01-19 15:03 ` nick.child at ibm dot com
2021-02-08 21:29 ` willschm at gcc dot gnu.org
2021-02-08 21:40 ` mark at gcc dot gnu.org
2021-02-08 22:00 ` willschm at gcc dot gnu.org
2021-02-09  9:34 ` mark at gcc dot gnu.org
2021-02-09  9:44 ` mark at gcc dot gnu.org
2021-02-09 21:04 ` willschm at gcc dot gnu.org
2021-02-09 22:12 ` segher at gcc dot gnu.org
2021-02-09 22:21 ` segher at gcc dot gnu.org
2021-02-10  9:38 ` mark at gcc dot gnu.org
2021-02-10 14:09 ` mark at gcc dot gnu.org
2021-02-10 14:35 ` jseward at acm dot org
2021-02-10 14:44 ` jakub at gcc dot gnu.org
2021-02-10 14:51 ` jseward at acm dot org
2021-02-10 14:53 ` jseward at acm dot org
2021-02-10 16:31 ` segher at gcc dot gnu.org
2021-02-10 16:34 ` segher at gcc dot gnu.org

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).