perf unwind: Fix uninitialized variable
Ian Rogers
reviewerPATCH 1/1 perf unwind: Fix uninitialized variable
ret may be uninitialized on error goto paths.
--- tools/perf/util/unwind-libunwind-local.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/unwind-libunwind-local.c +1 -1
@@ -174,7 +174,7 @@ static int elf_section_address_and_offset(int fd, const char *name, u64 *addressElf *elf;GElf_Ehdr ehdr;GElf_Shdr shdr; -int ret; +int ret =-1 ; elf =elf_begin (fd,PERF_ELF_C_READ_MMAP ,NULL );if (elf ==NULL )
Signature · 1 line
2.36.1.255.ge46751e96f-goog
Quoted 5 lines · Ian Rogers
ret may be uninitialized on error goto paths.
Reported-by Sedat Dilek <[email protected]>Fixes dc2cf4ca866f ("perf unwind: Fix segbase for ld.lld linked objects")Signed-off-by Ian Rogers <[email protected]>
Thanks. Sorry for my mistake...
Quoted 20 lines
---
tools/perf/util/unwind-libunwind-local.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/unwind-libunwind-local.c +1
-1@@ -174,7 +174,7 @@ static int elf_section_address_and_offset(int fd, const char *name, u64 *addressElf *elf;GElf_Ehdr ehdr;GElf_Shdr shdr; -int ret; +int ret =-1 ; elf =elf_begin (fd,PERF_ELF_C_READ_MMAP ,NULL );if (elf ==NULL )Signature · 1 line
2.36.1.255.ge46751e96f-goog
Em Mon, Jun 06, 2022 at 05:26:58PM -0700, Fangrui Song escreveu:
Quoted 10 lines · Ian Rogers
Quoted 5 lines
ret may be uninitialized on error goto paths.
Reported-by Sedat Dilek <[email protected]>Fixes dc2cf4ca866f ("perf unwind: Fix segbase for ld.lld linked objects")Signed-off-by Ian Rogers <[email protected]>Thanks. Sorry for my mistake...
Reviewed-by Fangrui Song <[email protected]>
Thanks, applied.
- Arnaldo
Quoted 20 lines
Quoted 20 lines
---
tools/perf/util/unwind-libunwind-local.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/unwind-libunwind-local.c +1
-1@@ -174,7 +174,7 @@ static int elf_section_address_and_offset(int fd, const char *name, u64 *addressElf *elf;GElf_Ehdr ehdr;GElf_Shdr shdr; -int ret; +int ret =-1 ; elf =elf_begin (fd,PERF_ELF_C_READ_MMAP ,NULL );if (elf ==NULL )Signature · 1 line
2.36.1.255.ge46751e96f-goog
Signature · 1 line
- Arnaldo
Quoted 6 lines · Ian Rogers
ret may be uninitialized on error goto paths.
Reported-by Sedat Dilek <[email protected]>Fixes dc2cf4ca866f ("perf unwind: Fix segbase for ld.lld linked objects")Signed-off-by Ian Rogers <[email protected]>
Thanks for the patch.
Feel free to add my:
$ LC_ALL=C ll ~/bin/perf -rwxr-xr-x 2 dileks dileks 16M Jun 7 20:10 /home/dileks/bin/perf
$ ~/bin/perf -vv
perf version 5.19.0-rc1
dwarf: [ on ] # HAVE_DWARF_SUPPORT
dwarf_getlocations: [ on ] # HAVE_DWARF_GETLOCATIONS_SUPPORT
glibc: [ on ] # HAVE_GLIBC_SUPPORT
syscall_table: [ on ] # HAVE_SYSCALL_TABLE_SUPPORT
libbfd: [ on ] # HAVE_LIBBFD_SUPPORT
debuginfod: [ OFF ] # HAVE_DEBUGINFOD_SUPPORT
libelf: [ on ] # HAVE_LIBELF_SUPPORT
libnuma: [ on ] # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on ] # HAVE_LIBNUMA_SUPPORT
libperl: [ on ] # HAVE_LIBPERL_SUPPORT
libpython: [ on ] # HAVE_LIBPYTHON_SUPPORT
libslang: [ on ] # HAVE_SLANG_SUPPORT
libcrypto: [ on ] # HAVE_LIBCRYPTO_SUPPORT
libunwind: [ on ] # HAVE_LIBUNWIND_SUPPORT
libdw-dwarf-unwind: [ on ] # HAVE_DWARF_SUPPORT
zlib: [ on ] # HAVE_ZLIB_SUPPORT
lzma: [ on ] # HAVE_LZMA_SUPPORT
get_cpuid: [ on ] # HAVE_AUXTRACE_SUPPORT
bpf: [ on ] # HAVE_LIBBPF_SUPPORT
aio: [ on ] # HAVE_AIO_SUPPORT
zstd: [ on ] # HAVE_ZSTD_SUPPORT
libpfm4: [ OFF ] # HAVE_LIBPFM-Sedat-
Quoted 20 lines
--- tools/perf/util/unwind-libunwind-local.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/unwind-libunwind-local.c +1
-2@@ -174,7 +174,7 @@ static int elf_section_address_and_offset(int fd, const char *name, u64 *addressElf *elf;GElf_Ehdr ehdr;GElf_Shdr shdr; -int ret; +int ret =-1 ; elf =elf_begin (fd,PERF_ELF_C_READ_MMAP ,NULL );if (elf ==NULL ) --2.36.1.255.ge46751e96f-goog
Sedat Dilek
Tested-byQuoted 9 lines · Sedat Dilek
Quoted 6 lines · Ian Rogers
ret may be uninitialized on error goto paths.
Reported-by Sedat Dilek <[email protected]>Fixes dc2cf4ca866f ("perf unwind: Fix segbase for ld.lld linked objects")Signed-off-by Ian Rogers <[email protected]>
Quoted 6 lines
Thanks for the patch.
Feel free to add my:
Tested-by Sedat Dilek <[email protected]>
If it is not too late, more exactly:
-Sedat-
Quoted 50 lines
$ LC_ALL=C ll ~/bin/perf -rwxr-xr-x 2 dileks dileks 16M Jun 7 20:10 /home/dileks/bin/perf$ ~/bin/perf -vv perf version 5.19.0-rc1 dwarf: [ on ] # HAVE_DWARF_SUPPORT dwarf_getlocations: [ on ] # HAVE_DWARF_GETLOCATIONS_SUPPORT glibc: [ on ] # HAVE_GLIBC_SUPPORT syscall_table: [ on ] # HAVE_SYSCALL_TABLE_SUPPORT libbfd: [ on ] # HAVE_LIBBFD_SUPPORT debuginfod: [ OFF ] # HAVE_DEBUGINFOD_SUPPORT libelf: [ on ] # HAVE_LIBELF_SUPPORT libnuma: [ on ] # HAVE_LIBNUMA_SUPPORT numa_num_possible_cpus: [ on ] # HAVE_LIBNUMA_SUPPORT libperl: [ on ] # HAVE_LIBPERL_SUPPORT libpython: [ on ] # HAVE_LIBPYTHON_SUPPORT libslang: [ on ] # HAVE_SLANG_SUPPORT libcrypto: [ on ] # HAVE_LIBCRYPTO_SUPPORT libunwind: [ on ] # HAVE_LIBUNWIND_SUPPORT libdw-dwarf-unwind: [ on ] # HAVE_DWARF_SUPPORT zlib: [ on ] # HAVE_ZLIB_SUPPORT lzma: [ on ] # HAVE_LZMA_SUPPORT get_cpuid: [ on ] # HAVE_AUXTRACE_SUPPORT bpf: [ on ] # HAVE_LIBBPF_SUPPORT aio: [ on ] # HAVE_AIO_SUPPORT zstd: [ on ] # HAVE_ZSTD_SUPPORT libpfm4: [ OFF ] # HAVE_LIBPFM-Sedat-
Quoted 20 lines
--- tools/perf/util/unwind-libunwind-local.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/unwind-libunwind-local.c +1
-2@@ -174,7 +174,7 @@ static int elf_section_address_and_offset(int fd, const char *name, u64 *addressElf *elf;GElf_Ehdr ehdr;GElf_Shdr shdr; -int ret; +int ret =-1 ; elf =elf_begin (fd,PERF_ELF_C_READ_MMAP ,NULL );if (elf ==NULL ) --2.36.1.255.ge46751e96f-goog
[Linux v5.19-rc1] tools/perf/a.out remains after make -C tools/perf clean
In reply to Ian RogersHi,
I observed this some time ago - so this is not only Linux v5.19-rc1 related.
$ LC_ALL=C make -C tools/perf clean 2>&1 | tee ../make-log_perf-clean.txt make: Entering directory '/home/dileks/src/linux-kernel/git/tools/perf' CLEAN x86 CLEAN libtraceevent CLEAN libapi CLEAN libbpf CLEAN libsubcmd CLEAN libperf CLEAN fixdep CLEAN feature-detect CLEAN python CLEAN bpf-skel CLEAN core-objs CLEAN core-progs CLEAN core-gen CLEAN Documentation make: Leaving directory '/home/dileks/src/linux-kernel/git/tools/perf'
$ git status -s M tools/perf/util/unwind-libunwind-local.c ?? tools/perf/a.out
$ rm -v tools/perf/a.out 'tools/perf/a.out' deleted
$ git checkout -- tools/perf/util/unwind-libunwind-local.c
$ git status -s [ empty ]
Thanks.
Regards,
-Sedat-
Arnaldo Carvalho de Melo
maintainerRe: [Linux v5.19-rc1] tools/perf/a.out remains after make -C tools/perf clean
Em Tue, Jun 07, 2022 at 08:59:31PM +0200, Sedat Dilek escreveu:
Quoted 26 lines
Hi,
I observed this some time ago - so this is not only Linux v5.19-rc1 related.
$ LC_ALL=C make -C tools/perf clean 2>&1 | tee ../make-log_perf-clean.txt make: Entering directory '/home/dileks/src/linux-kernel/git/tools/perf' CLEAN x86 CLEAN libtraceevent CLEAN libapi CLEAN libbpf CLEAN libsubcmd CLEAN libperf CLEAN fixdep CLEAN feature-detect CLEAN python CLEAN bpf-skel CLEAN core-objs CLEAN core-progs CLEAN core-gen CLEAN Documentation make: Leaving directory '/home/dileks/src/linux-kernel/git/tools/perf'$ git status -s M tools/perf/util/unwind-libunwind-local.c ?? tools/perf/a.out
Quoted 7 lines
$ rm -v tools/perf/a.out 'tools/perf/a.out' deleted$ git checkout -- tools/perf/util/unwind-libunwind-local.c$ git status -s [ empty ]
Interesting, since Linus complained at some point that after building perf some new temp file was left there I added 'git status' to my scripts to always get this flagged.
I'm not seeing this here.
- Arnaldo
Re: [Linux v5.19-rc1] tools/perf/a.out remains after make -C tools/perf clean
Quoted 33 lines · Arnaldo Carvalho de Melo
Em Tue, Jun 07, 2022 at 08:59:31PM +0200, Sedat Dilek escreveu:
Quoted 31 lines
Hi,
I observed this some time ago - so this is not only Linux v5.19-rc1 related.
$ LC_ALL=C make -C tools/perf clean 2>&1 | tee ../make-log_perf-clean.txt make: Entering directory '/home/dileks/src/linux-kernel/git/tools/perf' CLEAN x86 CLEAN libtraceevent CLEAN libapi CLEAN libbpf CLEAN libsubcmd CLEAN libperf CLEAN fixdep CLEAN feature-detect CLEAN python CLEAN bpf-skel CLEAN core-objs CLEAN core-progs CLEAN core-gen CLEAN Documentation make: Leaving directory '/home/dileks/src/linux-kernel/git/tools/perf'$ git status -s M tools/perf/util/unwind-libunwind-local.c ?? tools/perf/a.out$ rm -v tools/perf/a.out 'tools/perf/a.out' deleted$ git checkout -- tools/perf/util/unwind-libunwind-local.c
Quoted 9 lines
Quoted 2 lines
$ git status -s [ empty ]Interesting, since Linus complained at some point that after building perf some new temp file was left there I added 'git status' to my scripts to always get this flagged.
I'm not seeing this here.
Just re-checked with Linux v5.19-rc2 and attaching tools/perf/a.out + tools/perf/Makefile.config.
Check perf binary:
$ ~/bin/perf -vv
perf version 5.19.0-rc2
dwarf: [ on ] # HAVE_DWARF_SUPPORT
dwarf_getlocations: [ on ] # HAVE_DWARF_GETLOCATIONS_SUPPORT
glibc: [ on ] # HAVE_GLIBC_SUPPORT
syscall_table: [ on ] # HAVE_SYSCALL_TABLE_SUPPORT
libbfd: [ on ] # HAVE_LIBBFD_SUPPORT
debuginfod: [ OFF ] # HAVE_DEBUGINFOD_SUPPORT
libelf: [ on ] # HAVE_LIBELF_SUPPORT
libnuma: [ on ] # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on ] # HAVE_LIBNUMA_SUPPORT
libperl: [ on ] # HAVE_LIBPERL_SUPPORT
libpython: [ on ] # HAVE_LIBPYTHON_SUPPORT
libslang: [ on ] # HAVE_SLANG_SUPPORT
libcrypto: [ on ] # HAVE_LIBCRYPTO_SUPPORT
libunwind: [ on ] # HAVE_LIBUNWIND_SUPPORT
libdw-dwarf-unwind: [ on ] # HAVE_DWARF_SUPPORT
zlib: [ on ] # HAVE_ZLIB_SUPPORT
lzma: [ on ] # HAVE_LZMA_SUPPORT
get_cpuid: [ on ] # HAVE_AUXTRACE_SUPPORT
bpf: [ on ] # HAVE_LIBBPF_SUPPORT
aio: [ on ] # HAVE_AIO_SUPPORT
zstd: [ on ] # HAVE_ZSTD_SUPPORT
libpfm4: [ OFF ] # HAVE_LIBPFMTried make distclean.
Tried make tools/ clean but tools/tracing/rtla produces errors (rm clean). Still exists: tools/perf/a.out.
-Sedat-
Arnaldo Carvalho de Melo
maintainerRe: [Linux v5.19-rc1] tools/perf/a.out remains after make -C tools/perf clean
Em Wed, Jun 15, 2022 at 12:11:48AM +0200, Sedat Dilek escreveu:
Quoted 75 lines
Quoted 33 lines · Arnaldo Carvalho de Melo
Em Tue, Jun 07, 2022 at 08:59:31PM +0200, Sedat Dilek escreveu:
Quoted 31 lines
Hi,
I observed this some time ago - so this is not only Linux v5.19-rc1 related.
$ LC_ALL=C make -C tools/perf clean 2>&1 | tee ../make-log_perf-clean.txt make: Entering directory '/home/dileks/src/linux-kernel/git/tools/perf' CLEAN x86 CLEAN libtraceevent CLEAN libapi CLEAN libbpf CLEAN libsubcmd CLEAN libperf CLEAN fixdep CLEAN feature-detect CLEAN python CLEAN bpf-skel CLEAN core-objs CLEAN core-progs CLEAN core-gen CLEAN Documentation make: Leaving directory '/home/dileks/src/linux-kernel/git/tools/perf'$ git status -s M tools/perf/util/unwind-libunwind-local.c ?? tools/perf/a.out$ rm -v tools/perf/a.out 'tools/perf/a.out' deleted$ git checkout -- tools/perf/util/unwind-libunwind-local.cQuoted 9 lines
Quoted 2 lines
$ git status -s [ empty ]Interesting, since Linus complained at some point that after building perf some new temp file was left there I added 'git status' to my scripts to always get this flagged.
I'm not seeing this here.
Just re-checked with Linux v5.19-rc2 and attaching
tools/perf/a.out+tools/perf/Makefile.config.Check perf binary:
$ ~/bin/perf -vv perf version 5.19.0-rc2 dwarf: [ on ] # HAVE_DWARF_SUPPORT dwarf_getlocations: [ on ] # HAVE_DWARF_GETLOCATIONS_SUPPORT glibc: [ on ] # HAVE_GLIBC_SUPPORT syscall_table: [ on ] # HAVE_SYSCALL_TABLE_SUPPORT libbfd: [ on ] # HAVE_LIBBFD_SUPPORT debuginfod: [ OFF ] # HAVE_DEBUGINFOD_SUPPORT libelf: [ on ] # HAVE_LIBELF_SUPPORT libnuma: [ on ] # HAVE_LIBNUMA_SUPPORT numa_num_possible_cpus: [ on ] # HAVE_LIBNUMA_SUPPORT libperl: [ on ] # HAVE_LIBPERL_SUPPORT libpython: [ on ] # HAVE_LIBPYTHON_SUPPORT libslang: [ on ] # HAVE_SLANG_SUPPORT libcrypto: [ on ] # HAVE_LIBCRYPTO_SUPPORT libunwind: [ on ] # HAVE_LIBUNWIND_SUPPORT libdw-dwarf-unwind: [ on ] # HAVE_DWARF_SUPPORT zlib: [ on ] # HAVE_ZLIB_SUPPORT lzma: [ on ] # HAVE_LZMA_SUPPORT get_cpuid: [ on ] # HAVE_AUXTRACE_SUPPORT bpf: [ on ] # HAVE_LIBBPF_SUPPORT aio: [ on ] # HAVE_AIO_SUPPORT zstd: [ on ] # HAVE_ZSTD_SUPPORT libpfm4: [ OFF ] # HAVE_LIBPFM
Quoted 3 lines
Tried
make distclean.
Triedmake tools/ cleanbuttools/tracing/rtlaproduces errors (rm clean). Still exists:tools/perf/a.out.
I started seeing this here, will investigate and re-read your reports, thanks for sending them!
- Arnaldo
Re: [Linux v5.19-rc1] tools/perf/a.out remains after make -C tools/perf clean
Quoted 77 lines · Arnaldo Carvalho de Melo
Em Wed, Jun 15, 2022 at 12:11:48AM +0200, Sedat Dilek escreveu:
Quoted 75 lines
Quoted 33 lines · Arnaldo Carvalho de Melo
Em Tue, Jun 07, 2022 at 08:59:31PM +0200, Sedat Dilek escreveu:
Quoted 31 lines
Hi,
I observed this some time ago - so this is not only Linux v5.19-rc1 related.
$ LC_ALL=C make -C tools/perf clean 2>&1 | tee ../make-log_perf-clean.txt make: Entering directory '/home/dileks/src/linux-kernel/git/tools/perf' CLEAN x86 CLEAN libtraceevent CLEAN libapi CLEAN libbpf CLEAN libsubcmd CLEAN libperf CLEAN fixdep CLEAN feature-detect CLEAN python CLEAN bpf-skel CLEAN core-objs CLEAN core-progs CLEAN core-gen CLEAN Documentation make: Leaving directory '/home/dileks/src/linux-kernel/git/tools/perf'$ git status -s M tools/perf/util/unwind-libunwind-local.c ?? tools/perf/a.out$ rm -v tools/perf/a.out 'tools/perf/a.out' deleted$ git checkout -- tools/perf/util/unwind-libunwind-local.cQuoted 9 lines
Quoted 2 lines
$ git status -s [ empty ]Interesting, since Linus complained at some point that after building perf some new temp file was left there I added 'git status' to my scripts to always get this flagged.
I'm not seeing this here.
Just re-checked with Linux v5.19-rc2 and attaching
tools/perf/a.out+tools/perf/Makefile.config.Check perf binary:
$ ~/bin/perf -vv perf version 5.19.0-rc2 dwarf: [ on ] # HAVE_DWARF_SUPPORT dwarf_getlocations: [ on ] # HAVE_DWARF_GETLOCATIONS_SUPPORT glibc: [ on ] # HAVE_GLIBC_SUPPORT syscall_table: [ on ] # HAVE_SYSCALL_TABLE_SUPPORT libbfd: [ on ] # HAVE_LIBBFD_SUPPORT debuginfod: [ OFF ] # HAVE_DEBUGINFOD_SUPPORT libelf: [ on ] # HAVE_LIBELF_SUPPORT libnuma: [ on ] # HAVE_LIBNUMA_SUPPORT numa_num_possible_cpus: [ on ] # HAVE_LIBNUMA_SUPPORT libperl: [ on ] # HAVE_LIBPERL_SUPPORT libpython: [ on ] # HAVE_LIBPYTHON_SUPPORT libslang: [ on ] # HAVE_SLANG_SUPPORT libcrypto: [ on ] # HAVE_LIBCRYPTO_SUPPORT libunwind: [ on ] # HAVE_LIBUNWIND_SUPPORT libdw-dwarf-unwind: [ on ] # HAVE_DWARF_SUPPORT zlib: [ on ] # HAVE_ZLIB_SUPPORT lzma: [ on ] # HAVE_LZMA_SUPPORT get_cpuid: [ on ] # HAVE_AUXTRACE_SUPPORT bpf: [ on ] # HAVE_LIBBPF_SUPPORT aio: [ on ] # HAVE_AIO_SUPPORT zstd: [ on ] # HAVE_ZSTD_SUPPORT libpfm4: [ OFF ] # HAVE_LIBPFM
Quoted 7 lines
Quoted 3 lines
Tried
make distclean.
Triedmake tools/ cleanbuttools/tracing/rtlaproduces errors (rm clean). Still exists:tools/perf/a.out.I started seeing this here, will investigate and re-read your reports, thanks for sending them!
Thanks for the feedback.
If you need further information or have something for testing, please let me know.
-sed@-
Arnaldo Carvalho de Melo
maintainerRe: [Linux v5.19-rc1] tools/perf/a.out remains after make -C tools/perf clean
In reply to Arnaldo Carvalho de MeloEm Sun, Jun 26, 2022 at 12:31:05PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 6 lines
Em Wed, Jun 15, 2022 at 12:11:48AM +0200, Sedat Dilek escreveu:
Quoted 5 lines
bpf: [ on ] # HAVE_LIBBPF_SUPPORT aio: [ on ] # HAVE_AIO_SUPPORT zstd: [ on ] # HAVE_ZSTD_SUPPORT libpfm4: [ OFF ] # HAVE_LIBPFM
Quoted 6 lines
Quoted 3 lines
Tried
make distclean.
Triedmake tools/ cleanbuttools/tracing/rtlaproduces errors (rm clean). Still exists:tools/perf/a.out.I started seeing this here, will investigate and re-read your reports, thanks for sending them!
This is only happening when I use CC=clang, here I have clang 13, just making a note, seems related to a feature check, tools/build/feature/test-hello.c.
- Arnaldo