public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [libbacktrace] Initialize st in elf_is_symlink
@ 2019-03-18  2:54 james.hilliard1
  2019-03-18 17:35 ` Ian Lance Taylor via gcc-patches
  0 siblings, 1 reply; 13+ messages in thread
From: james.hilliard1 @ 2019-03-18  2:54 UTC (permalink / raw)
  To: gcc-patches; +Cc: James Hilliard

From: James Hilliard <james.hilliard1@gmail.com>

Fixes error: ‘st.st_mode’ may be used uninitialized in this function
---
 libbacktrace/elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index f3988ec02a0..714bfec965d 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -765,7 +765,7 @@ elf_syminfo (struct backtrace_state *state, uintptr_t addr,
 static int
 elf_is_symlink (const char *filename)
 {
-  struct stat st;
+  struct stat st={0};
 
   if (lstat (filename, &st) < 0)
     return 0;
-- 
2.17.1

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

* Re: [PATCH] [libbacktrace] Initialize st in elf_is_symlink
  2019-03-18  2:54 [PATCH] [libbacktrace] Initialize st in elf_is_symlink james.hilliard1
@ 2019-03-18 17:35 ` Ian Lance Taylor via gcc-patches
  2019-03-18 19:03   ` James Hilliard
  0 siblings, 1 reply; 13+ messages in thread
From: Ian Lance Taylor via gcc-patches @ 2019-03-18 17:35 UTC (permalink / raw)
  To: james.hilliard1; +Cc: gcc-patches

On Sun, Mar 17, 2019 at 6:22 PM <james.hilliard1@gmail.com> wrote:
>
> From: James Hilliard <james.hilliard1@gmail.com>
>
> Fixes error: ‘st.st_mode’ may be used uninitialized in this function
> ---
>  libbacktrace/elf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
> index f3988ec02a0..714bfec965d 100644
> --- a/libbacktrace/elf.c
> +++ b/libbacktrace/elf.c
> @@ -765,7 +765,7 @@ elf_syminfo (struct backtrace_state *state, uintptr_t addr,
>  static int
>  elf_is_symlink (const char *filename)
>  {
> -  struct stat st;
> +  struct stat st={0};
>
>    if (lstat (filename, &st) < 0)
>      return 0;

I can't see why that is needed.  The variable is initialized right
there on the next non-blank line.  If the compiler is giving a
warning, then we need to fix the compiler.

Ian

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

* Re: [PATCH] [libbacktrace] Initialize st in elf_is_symlink
  2019-03-18 17:35 ` Ian Lance Taylor via gcc-patches
@ 2019-03-18 19:03   ` James Hilliard
  2019-03-18 20:09     ` Ian Lance Taylor via gcc-patches
  0 siblings, 1 reply; 13+ messages in thread
From: James Hilliard @ 2019-03-18 19:03 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-patches

On Mon, Mar 18, 2019 at 11:19 AM Ian Lance Taylor <iant@google.com> wrote:
>
> On Sun, Mar 17, 2019 at 6:22 PM <james.hilliard1@gmail.com> wrote:
> >
> > From: James Hilliard <james.hilliard1@gmail.com>
> >
> > Fixes error: ‘st.st_mode’ may be used uninitialized in this function
> > ---
> >  libbacktrace/elf.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
> > index f3988ec02a0..714bfec965d 100644
> > --- a/libbacktrace/elf.c
> > +++ b/libbacktrace/elf.c
> > @@ -765,7 +765,7 @@ elf_syminfo (struct backtrace_state *state, uintptr_t addr,
> >  static int
> >  elf_is_symlink (const char *filename)
> >  {
> > -  struct stat st;
> > +  struct stat st={0};
> >
> >    if (lstat (filename, &st) < 0)
> >      return 0;
>
> I can't see why that is needed.  The variable is initialized right
> there on the next non-blank line.  If the compiler is giving a
> warning, then we need to fix the compiler.
This is the message I get:
../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c: In
function ‘elf_is_symlink’:
../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21:
error: ‘st.st_mode’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
   return S_ISLNK (st.st_mode);
                     ^
>
> Ian

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

* Re: [PATCH] [libbacktrace] Initialize st in elf_is_symlink
  2019-03-18 19:03   ` James Hilliard
@ 2019-03-18 20:09     ` Ian Lance Taylor via gcc-patches
  2019-03-18 22:51       ` James Hilliard
  0 siblings, 1 reply; 13+ messages in thread
From: Ian Lance Taylor via gcc-patches @ 2019-03-18 20:09 UTC (permalink / raw)
  To: James Hilliard; +Cc: gcc-patches

On Mon, Mar 18, 2019 at 11:57 AM James Hilliard
<james.hilliard1@gmail.com> wrote:
>
> On Mon, Mar 18, 2019 at 11:19 AM Ian Lance Taylor <iant@google.com> wrote:
> >
> > On Sun, Mar 17, 2019 at 6:22 PM <james.hilliard1@gmail.com> wrote:
> > >
> > > From: James Hilliard <james.hilliard1@gmail.com>
> > >
> > > Fixes error: ‘st.st_mode’ may be used uninitialized in this function
> > > ---
> > >  libbacktrace/elf.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
> > > index f3988ec02a0..714bfec965d 100644
> > > --- a/libbacktrace/elf.c
> > > +++ b/libbacktrace/elf.c
> > > @@ -765,7 +765,7 @@ elf_syminfo (struct backtrace_state *state, uintptr_t addr,
> > >  static int
> > >  elf_is_symlink (const char *filename)
> > >  {
> > > -  struct stat st;
> > > +  struct stat st={0};
> > >
> > >    if (lstat (filename, &st) < 0)
> > >      return 0;
> >
> > I can't see why that is needed.  The variable is initialized right
> > there on the next non-blank line.  If the compiler is giving a
> > warning, then we need to fix the compiler.
> This is the message I get:
> ../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c: In
> function ‘elf_is_symlink’:
> ../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21:
> error: ‘st.st_mode’ may be used uninitialized in this function
> [-Werror=maybe-uninitialized]
>    return S_ISLNK (st.st_mode);
>                      ^

Thanks, but I'm saying that if you look at the code you can see that
st is clearly initialized, by the call to lstat.  I would like to see
an explanation for why you are seeing that warning before changing the
code to disable it.  Initializing st should not be necessary here.
For example, perhaps lstat is a macro when compiling libsanitizer; if
that is the underlying problem, then we should fix the macro, not this
code.

Ian

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

* Re: [PATCH] [libbacktrace] Initialize st in elf_is_symlink
  2019-03-18 20:09     ` Ian Lance Taylor via gcc-patches
@ 2019-03-18 22:51       ` James Hilliard
  2019-03-18 23:07         ` Jakub Jelinek
  0 siblings, 1 reply; 13+ messages in thread
From: James Hilliard @ 2019-03-18 22:51 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-patches

On Mon, Mar 18, 2019 at 2:05 PM Ian Lance Taylor <iant@google.com> wrote:
>
> On Mon, Mar 18, 2019 at 11:57 AM James Hilliard
> <james.hilliard1@gmail.com> wrote:
> >
> > On Mon, Mar 18, 2019 at 11:19 AM Ian Lance Taylor <iant@google.com> wrote:
> > >
> > > On Sun, Mar 17, 2019 at 6:22 PM <james.hilliard1@gmail.com> wrote:
> > > >
> > > > From: James Hilliard <james.hilliard1@gmail.com>
> > > >
> > > > Fixes error: ‘st.st_mode’ may be used uninitialized in this function
> > > > ---
> > > >  libbacktrace/elf.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
> > > > index f3988ec02a0..714bfec965d 100644
> > > > --- a/libbacktrace/elf.c
> > > > +++ b/libbacktrace/elf.c
> > > > @@ -765,7 +765,7 @@ elf_syminfo (struct backtrace_state *state, uintptr_t addr,
> > > >  static int
> > > >  elf_is_symlink (const char *filename)
> > > >  {
> > > > -  struct stat st;
> > > > +  struct stat st={0};
> > > >
> > > >    if (lstat (filename, &st) < 0)
> > > >      return 0;
> > >
> > > I can't see why that is needed.  The variable is initialized right
> > > there on the next non-blank line.  If the compiler is giving a
> > > warning, then we need to fix the compiler.
> > This is the message I get:
> > ../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c: In
> > function ‘elf_is_symlink’:
> > ../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21:
> > error: ‘st.st_mode’ may be used uninitialized in this function
> > [-Werror=maybe-uninitialized]
> >    return S_ISLNK (st.st_mode);
> >                      ^
>
> Thanks, but I'm saying that if you look at the code you can see that
> st is clearly initialized, by the call to lstat.  I would like to see
> an explanation for why you are seeing that warning before changing the
> code to disable it.  Initializing st should not be necessary here.
> For example, perhaps lstat is a macro when compiling libsanitizer; if
> that is the underlying problem, then we should fix the macro, not this
> code.
Yeah, I'm not sure why the compiler thinks lstat isn't initializing st.
What should I do to debug this further?
>
> Ian

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

* Re: [PATCH] [libbacktrace] Initialize st in elf_is_symlink
  2019-03-18 22:51       ` James Hilliard
@ 2019-03-18 23:07         ` Jakub Jelinek
  2019-03-18 23:46           ` James Hilliard
  0 siblings, 1 reply; 13+ messages in thread
From: Jakub Jelinek @ 2019-03-18 23:07 UTC (permalink / raw)
  To: James Hilliard; +Cc: Ian Lance Taylor, gcc-patches

On Mon, Mar 18, 2019 at 04:41:05PM -0600, James Hilliard wrote:
> > Thanks, but I'm saying that if you look at the code you can see that
> > st is clearly initialized, by the call to lstat.  I would like to see
> > an explanation for why you are seeing that warning before changing the
> > code to disable it.  Initializing st should not be necessary here.
> > For example, perhaps lstat is a macro when compiling libsanitizer; if
> > that is the underlying problem, then we should fix the macro, not this
> > code.
> Yeah, I'm not sure why the compiler thinks lstat isn't initializing st.
> What should I do to debug this further?

Guess you should start by telling us which OS it is on (I can't reproduce
this warning on x86_64-linux nor i686-linux with glibc 2.28), looking at
preprocessed source to see what exactly lstat does (e.g. if it is some macro
or inline function and what exactly it is doing).

	Jakub

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

* Re: [PATCH] [libbacktrace] Initialize st in elf_is_symlink
  2019-03-18 23:07         ` Jakub Jelinek
@ 2019-03-18 23:46           ` James Hilliard
  2019-03-19  0:09             ` Jeff Law
  0 siblings, 1 reply; 13+ messages in thread
From: James Hilliard @ 2019-03-18 23:46 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Ian Lance Taylor, gcc-patches

On Mon, Mar 18, 2019 at 4:51 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Mon, Mar 18, 2019 at 04:41:05PM -0600, James Hilliard wrote:
> > > Thanks, but I'm saying that if you look at the code you can see that
> > > st is clearly initialized, by the call to lstat.  I would like to see
> > > an explanation for why you are seeing that warning before changing the
> > > code to disable it.  Initializing st should not be necessary here.
> > > For example, perhaps lstat is a macro when compiling libsanitizer; if
> > > that is the underlying problem, then we should fix the macro, not this
> > > code.
> > Yeah, I'm not sure why the compiler thinks lstat isn't initializing st.
> > What should I do to debug this further?
>
> Guess you should start by telling us which OS it is on (I can't reproduce
> this warning on x86_64-linux nor i686-linux with glibc 2.28), looking at
> preprocessed source to see what exactly lstat does (e.g. if it is some macro
> or inline function and what exactly it is doing).
I am cross compiling with buildroot master branch using ubuntu 18.10.
I am building gcc 8.3.0 and glibc 2.29 for the cross toolchain.
The build and target systems are both x86_64.
>
>         Jakub

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

* Re: [PATCH] [libbacktrace] Initialize st in elf_is_symlink
  2019-03-18 23:46           ` James Hilliard
@ 2019-03-19  0:09             ` Jeff Law
  2019-03-19  0:58               ` James Hilliard
  0 siblings, 1 reply; 13+ messages in thread
From: Jeff Law @ 2019-03-19  0:09 UTC (permalink / raw)
  To: James Hilliard, Jakub Jelinek; +Cc: Ian Lance Taylor, gcc-patches

On 3/18/19 5:07 PM, James Hilliard wrote:
> On Mon, Mar 18, 2019 at 4:51 PM Jakub Jelinek <jakub@redhat.com> wrote:
>>
>> On Mon, Mar 18, 2019 at 04:41:05PM -0600, James Hilliard wrote:
>>>> Thanks, but I'm saying that if you look at the code you can see that
>>>> st is clearly initialized, by the call to lstat.  I would like to see
>>>> an explanation for why you are seeing that warning before changing the
>>>> code to disable it.  Initializing st should not be necessary here.
>>>> For example, perhaps lstat is a macro when compiling libsanitizer; if
>>>> that is the underlying problem, then we should fix the macro, not this
>>>> code.
>>> Yeah, I'm not sure why the compiler thinks lstat isn't initializing st.
>>> What should I do to debug this further?
>>
>> Guess you should start by telling us which OS it is on (I can't reproduce
>> this warning on x86_64-linux nor i686-linux with glibc 2.28), looking at
>> preprocessed source to see what exactly lstat does (e.g. if it is some macro
>> or inline function and what exactly it is doing).
> I am cross compiling with buildroot master branch using ubuntu 18.10.
> I am building gcc 8.3.0 and glibc 2.29 for the cross toolchain.
> The build and target systems are both x86_64.
Add "-save-temps" to the command line.  That will create a .i file, send
the .i file along with the command line.

jeff

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

* Re: [PATCH] [libbacktrace] Initialize st in elf_is_symlink
  2019-03-19  0:09             ` Jeff Law
@ 2019-03-19  0:58               ` James Hilliard
  2019-03-19  1:19                 ` Jeff Law
  2019-03-19 10:01                 ` Jakub Jelinek
  0 siblings, 2 replies; 13+ messages in thread
From: James Hilliard @ 2019-03-19  0:58 UTC (permalink / raw)
  To: Jeff Law; +Cc: Jakub Jelinek, Ian Lance Taylor, gcc-patches

On Mon, Mar 18, 2019 at 5:46 PM Jeff Law <law@redhat.com> wrote:
>
> On 3/18/19 5:07 PM, James Hilliard wrote:
> > On Mon, Mar 18, 2019 at 4:51 PM Jakub Jelinek <jakub@redhat.com> wrote:
> >>
> >> On Mon, Mar 18, 2019 at 04:41:05PM -0600, James Hilliard wrote:
> >>>> Thanks, but I'm saying that if you look at the code you can see that
> >>>> st is clearly initialized, by the call to lstat.  I would like to see
> >>>> an explanation for why you are seeing that warning before changing the
> >>>> code to disable it.  Initializing st should not be necessary here.
> >>>> For example, perhaps lstat is a macro when compiling libsanitizer; if
> >>>> that is the underlying problem, then we should fix the macro, not this
> >>>> code.
> >>> Yeah, I'm not sure why the compiler thinks lstat isn't initializing st.
> >>> What should I do to debug this further?
> >>
> >> Guess you should start by telling us which OS it is on (I can't reproduce
> >> this warning on x86_64-linux nor i686-linux with glibc 2.28), looking at
> >> preprocessed source to see what exactly lstat does (e.g. if it is some macro
> >> or inline function and what exactly it is doing).
> > I am cross compiling with buildroot master branch using ubuntu 18.10.
> > I am building gcc 8.3.0 and glibc 2.29 for the cross toolchain.
> > The build and target systems are both x86_64.
> Add "-save-temps" to the command line.  That will create a .i file, send
> the .i file along with the command line.
I added --save-temps to the cflags for the gcc package build.
Here's the command line log:
https://gist.githubusercontent.com/jameshilliard/015d972c26d1ec7bbbd1ad2d57d5dd3b/raw/7c848cdfba0967a681401de24ed6f4c86315d2d9/cli.log
Here's the elf.i fille:
https://gist.githubusercontent.com/jameshilliard/2a391d7292f3ba7412fe80e166c0f0e3/raw/63eb16ba9eff0b3ee668b16257b0948b2ca894a0/elf.i
>
> jeff

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

* Re: [PATCH] [libbacktrace] Initialize st in elf_is_symlink
  2019-03-19  0:58               ` James Hilliard
@ 2019-03-19  1:19                 ` Jeff Law
  2019-03-19  2:02                   ` James Hilliard
  2019-03-19 10:01                 ` Jakub Jelinek
  1 sibling, 1 reply; 13+ messages in thread
From: Jeff Law @ 2019-03-19  1:19 UTC (permalink / raw)
  To: James Hilliard; +Cc: Jakub Jelinek, Ian Lance Taylor, gcc-patches

On 3/18/19 6:35 PM, James Hilliard wrote:
> On Mon, Mar 18, 2019 at 5:46 PM Jeff Law <law@redhat.com> wrote:
>>
>> On 3/18/19 5:07 PM, James Hilliard wrote:
>>> On Mon, Mar 18, 2019 at 4:51 PM Jakub Jelinek <jakub@redhat.com> wrote:
>>>>
>>>> On Mon, Mar 18, 2019 at 04:41:05PM -0600, James Hilliard wrote:
>>>>>> Thanks, but I'm saying that if you look at the code you can see that
>>>>>> st is clearly initialized, by the call to lstat.  I would like to see
>>>>>> an explanation for why you are seeing that warning before changing the
>>>>>> code to disable it.  Initializing st should not be necessary here.
>>>>>> For example, perhaps lstat is a macro when compiling libsanitizer; if
>>>>>> that is the underlying problem, then we should fix the macro, not this
>>>>>> code.
>>>>> Yeah, I'm not sure why the compiler thinks lstat isn't initializing st.
>>>>> What should I do to debug this further?
>>>>
>>>> Guess you should start by telling us which OS it is on (I can't reproduce
>>>> this warning on x86_64-linux nor i686-linux with glibc 2.28), looking at
>>>> preprocessed source to see what exactly lstat does (e.g. if it is some macro
>>>> or inline function and what exactly it is doing).
>>> I am cross compiling with buildroot master branch using ubuntu 18.10.
>>> I am building gcc 8.3.0 and glibc 2.29 for the cross toolchain.
>>> The build and target systems are both x86_64.
>> Add "-save-temps" to the command line.  That will create a .i file, send
>> the .i file along with the command line.
> I added --save-temps to the cflags for the gcc package build.
> Here's the command line log:
> https://gist.githubusercontent.com/jameshilliard/015d972c26d1ec7bbbd1ad2d57d5dd3b/raw/7c848cdfba0967a681401de24ed6f4c86315d2d9/cli.log
> Here's the elf.i fille:
> https://gist.githubusercontent.com/jameshilliard/2a391d7292f3ba7412fe80e166c0f0e3/raw/63eb16ba9eff0b3ee668b16257b0948b2ca894a0/elf.i
Jakub -- I haven't looked at it in any detail, but the first thing that
jumps out at me is the -Og and the message:

> ../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c: In function ‘elf_is_symlink’:
> ../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: ‘st.st_mode’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    return S_ISLNK (st.st_mode);

It could be the issues we've see with SRA and aggregates that have led
to the discussion around breaking those into a distinct class of uninit
warnings because we don't handle them well.  I wouldn't be at all
surprised if it goes away at -O1 or -O2.

jeff

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

* Re: [PATCH] [libbacktrace] Initialize st in elf_is_symlink
  2019-03-19  1:19                 ` Jeff Law
@ 2019-03-19  2:02                   ` James Hilliard
  0 siblings, 0 replies; 13+ messages in thread
From: James Hilliard @ 2019-03-19  2:02 UTC (permalink / raw)
  To: Jeff Law; +Cc: Jakub Jelinek, Ian Lance Taylor, gcc-patches

On Mon, Mar 18, 2019 at 6:58 PM Jeff Law <law@redhat.com> wrote:
>
> On 3/18/19 6:35 PM, James Hilliard wrote:
> > On Mon, Mar 18, 2019 at 5:46 PM Jeff Law <law@redhat.com> wrote:
> >>
> >> On 3/18/19 5:07 PM, James Hilliard wrote:
> >>> On Mon, Mar 18, 2019 at 4:51 PM Jakub Jelinek <jakub@redhat.com> wrote:
> >>>>
> >>>> On Mon, Mar 18, 2019 at 04:41:05PM -0600, James Hilliard wrote:
> >>>>>> Thanks, but I'm saying that if you look at the code you can see that
> >>>>>> st is clearly initialized, by the call to lstat.  I would like to see
> >>>>>> an explanation for why you are seeing that warning before changing the
> >>>>>> code to disable it.  Initializing st should not be necessary here.
> >>>>>> For example, perhaps lstat is a macro when compiling libsanitizer; if
> >>>>>> that is the underlying problem, then we should fix the macro, not this
> >>>>>> code.
> >>>>> Yeah, I'm not sure why the compiler thinks lstat isn't initializing st.
> >>>>> What should I do to debug this further?
> >>>>
> >>>> Guess you should start by telling us which OS it is on (I can't reproduce
> >>>> this warning on x86_64-linux nor i686-linux with glibc 2.28), looking at
> >>>> preprocessed source to see what exactly lstat does (e.g. if it is some macro
> >>>> or inline function and what exactly it is doing).
> >>> I am cross compiling with buildroot master branch using ubuntu 18.10.
> >>> I am building gcc 8.3.0 and glibc 2.29 for the cross toolchain.
> >>> The build and target systems are both x86_64.
> >> Add "-save-temps" to the command line.  That will create a .i file, send
> >> the .i file along with the command line.
> > I added --save-temps to the cflags for the gcc package build.
> > Here's the command line log:
> > https://gist.githubusercontent.com/jameshilliard/015d972c26d1ec7bbbd1ad2d57d5dd3b/raw/7c848cdfba0967a681401de24ed6f4c86315d2d9/cli.log
> > Here's the elf.i fille:
> > https://gist.githubusercontent.com/jameshilliard/2a391d7292f3ba7412fe80e166c0f0e3/raw/63eb16ba9eff0b3ee668b16257b0948b2ca894a0/elf.i
> Jakub -- I haven't looked at it in any detail, but the first thing that
> jumps out at me is the -Og and the message:
>
> > ../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c: In function ‘elf_is_symlink’:
> > ../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: ‘st.st_mode’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> >    return S_ISLNK (st.st_mode);
>
> It could be the issues we've see with SRA and aggregates that have led
> to the discussion around breaking those into a distinct class of uninit
> warnings because we don't handle them well.  I wouldn't be at all
> surprised if it goes away at -O1 or -O2.
I did a rebuild with -O2 and it worked.
>
> jeff

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

* Re: [PATCH] [libbacktrace] Initialize st in elf_is_symlink
  2019-03-19  0:58               ` James Hilliard
  2019-03-19  1:19                 ` Jeff Law
@ 2019-03-19 10:01                 ` Jakub Jelinek
  2019-03-19 10:43                   ` James Hilliard
  1 sibling, 1 reply; 13+ messages in thread
From: Jakub Jelinek @ 2019-03-19 10:01 UTC (permalink / raw)
  To: James Hilliard; +Cc: Jeff Law, Ian Lance Taylor, gcc-patches

On Mon, Mar 18, 2019 at 06:35:12PM -0600, James Hilliard wrote:
> On Mon, Mar 18, 2019 at 5:46 PM Jeff Law <law@redhat.com> wrote:
> >
> > On 3/18/19 5:07 PM, James Hilliard wrote:
> > > On Mon, Mar 18, 2019 at 4:51 PM Jakub Jelinek <jakub@redhat.com> wrote:
> > >>
> > >> On Mon, Mar 18, 2019 at 04:41:05PM -0600, James Hilliard wrote:
> > >>>> Thanks, but I'm saying that if you look at the code you can see that
> > >>>> st is clearly initialized, by the call to lstat.  I would like to see
> > >>>> an explanation for why you are seeing that warning before changing the
> > >>>> code to disable it.  Initializing st should not be necessary here.
> > >>>> For example, perhaps lstat is a macro when compiling libsanitizer; if
> > >>>> that is the underlying problem, then we should fix the macro, not this
> > >>>> code.
> > >>> Yeah, I'm not sure why the compiler thinks lstat isn't initializing st.
> > >>> What should I do to debug this further?
> > >>
> > >> Guess you should start by telling us which OS it is on (I can't reproduce
> > >> this warning on x86_64-linux nor i686-linux with glibc 2.28), looking at
> > >> preprocessed source to see what exactly lstat does (e.g. if it is some macro
> > >> or inline function and what exactly it is doing).
> > > I am cross compiling with buildroot master branch using ubuntu 18.10.
> > > I am building gcc 8.3.0 and glibc 2.29 for the cross toolchain.
> > > The build and target systems are both x86_64.
> > Add "-save-temps" to the command line.  That will create a .i file, send
> > the .i file along with the command line.
> I added --save-temps to the cflags for the gcc package build.
> Here's the command line log:
> https://gist.githubusercontent.com/jameshilliard/015d972c26d1ec7bbbd1ad2d57d5dd3b/raw/7c848cdfba0967a681401de24ed6f4c86315d2d9/cli.log
> Here's the elf.i fille:
> https://gist.githubusercontent.com/jameshilliard/2a391d7292f3ba7412fe80e166c0f0e3/raw/63eb16ba9eff0b3ee668b16257b0948b2ca894a0/elf.i

I still can't reproduce it, even with gcc 8.3.0:
/d/gcc-8.3.0/objdir/gcc/xgcc -B /d/gcc-8.3.0/objdir/gcc/ -S -g3 -Og elf.i -W -Wall -Wwrite-strings -Wmissing-format-attribute -Wcast-qual -Werror -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -fPIC -Wno-implicit-fallthrough
doesn't print anything.

	Jakub

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

* Re: [PATCH] [libbacktrace] Initialize st in elf_is_symlink
  2019-03-19 10:01                 ` Jakub Jelinek
@ 2019-03-19 10:43                   ` James Hilliard
  0 siblings, 0 replies; 13+ messages in thread
From: James Hilliard @ 2019-03-19 10:43 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Jeff Law, Ian Lance Taylor, gcc-patches

On Tue, Mar 19, 2019 at 3:56 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Mon, Mar 18, 2019 at 06:35:12PM -0600, James Hilliard wrote:
> > On Mon, Mar 18, 2019 at 5:46 PM Jeff Law <law@redhat.com> wrote:
> > >
> > > On 3/18/19 5:07 PM, James Hilliard wrote:
> > > > On Mon, Mar 18, 2019 at 4:51 PM Jakub Jelinek <jakub@redhat.com> wrote:
> > > >>
> > > >> On Mon, Mar 18, 2019 at 04:41:05PM -0600, James Hilliard wrote:
> > > >>>> Thanks, but I'm saying that if you look at the code you can see that
> > > >>>> st is clearly initialized, by the call to lstat.  I would like to see
> > > >>>> an explanation for why you are seeing that warning before changing the
> > > >>>> code to disable it.  Initializing st should not be necessary here.
> > > >>>> For example, perhaps lstat is a macro when compiling libsanitizer; if
> > > >>>> that is the underlying problem, then we should fix the macro, not this
> > > >>>> code.
> > > >>> Yeah, I'm not sure why the compiler thinks lstat isn't initializing st.
> > > >>> What should I do to debug this further?
> > > >>
> > > >> Guess you should start by telling us which OS it is on (I can't reproduce
> > > >> this warning on x86_64-linux nor i686-linux with glibc 2.28), looking at
> > > >> preprocessed source to see what exactly lstat does (e.g. if it is some macro
> > > >> or inline function and what exactly it is doing).
> > > > I am cross compiling with buildroot master branch using ubuntu 18.10.
> > > > I am building gcc 8.3.0 and glibc 2.29 for the cross toolchain.
> > > > The build and target systems are both x86_64.
> > > Add "-save-temps" to the command line.  That will create a .i file, send
> > > the .i file along with the command line.
> > I added --save-temps to the cflags for the gcc package build.
> > Here's the command line log:
> > https://gist.githubusercontent.com/jameshilliard/015d972c26d1ec7bbbd1ad2d57d5dd3b/raw/7c848cdfba0967a681401de24ed6f4c86315d2d9/cli.log
> > Here's the elf.i fille:
> > https://gist.githubusercontent.com/jameshilliard/2a391d7292f3ba7412fe80e166c0f0e3/raw/63eb16ba9eff0b3ee668b16257b0948b2ca894a0/elf.i
>
> I still can't reproduce it, even with gcc 8.3.0:
> /d/gcc-8.3.0/objdir/gcc/xgcc -B /d/gcc-8.3.0/objdir/gcc/ -S -g3 -Og elf.i -W -Wall -Wwrite-strings -Wmissing-format-attribute -Wcast-qual -Werror -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -fPIC -Wno-implicit-fallthrough
> doesn't print anything.
Try downloading buildroot(git commit
0af24710da70b04947229333c9450c86499b3108) and use this defconfig which
should reproduce the problem:
https://gist.github.com/jameshilliard/80e61f58e05e1325e0dbc6e30a11c851/raw/8e7d67cd1cc48f94b50e21f1ec407f29fe1dfe37/defconfig
>
>         Jakub

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

end of thread, other threads:[~2019-03-19 10:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18  2:54 [PATCH] [libbacktrace] Initialize st in elf_is_symlink james.hilliard1
2019-03-18 17:35 ` Ian Lance Taylor via gcc-patches
2019-03-18 19:03   ` James Hilliard
2019-03-18 20:09     ` Ian Lance Taylor via gcc-patches
2019-03-18 22:51       ` James Hilliard
2019-03-18 23:07         ` Jakub Jelinek
2019-03-18 23:46           ` James Hilliard
2019-03-19  0:09             ` Jeff Law
2019-03-19  0:58               ` James Hilliard
2019-03-19  1:19                 ` Jeff Law
2019-03-19  2:02                   ` James Hilliard
2019-03-19 10:01                 ` Jakub Jelinek
2019-03-19 10:43                   ` James Hilliard

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