Bug 30365 - [Objdump] Use of uninitialised value at prdbg.c
Summary: [Objdump] Use of uninitialised value at prdbg.c
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.41
Assignee: Alan Modra
URL:
Keywords:
: 30366 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-04-17 17:01 UTC by Ziqiao Kong
Modified: 2023-04-18 01:51 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed: 2023-04-18 00:00:00


Attachments
Both full logs and the object file (1.65 KB, application/x-xz)
2023-04-17 17:01 UTC, Ziqiao Kong
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ziqiao Kong 2023-04-17 17:01:37 UTC
Created attachment 14833 [details]
Both full logs and the object file

Git commit hash: 93c6e8c3c14bf81020ca7571fe752250a34f5bc9

Steps to reproduce:

```
./configure
make -j
valgrind --leak-check=full --tool=memcheck ./binutils/objdump -D /path/to/obj 
```

Valgrind output:

```
==535033== Memcheck, a memory error detector
==535033== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==535033== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==535033== Command: /binutils/binutils/objdump -g ./objdump-eval3-msan/msanchild120/crashes/id:000000,sig:09,src:021620+014111,time:65035916,execs:9404945,op:splice,rep:8,+san
==535033==
==535033== Conditional jump or move depends on uninitialised value(s)
==535033==    at 0x19768B: pr_struct_field (prdbg.c:1118)
==535033==    by 0x19768B: pr_struct_field (prdbg.c:1105)
==535033==    by 0x199C2B: debug_write_type (debug.c:2541)
==535033==    by 0x19A57E: debug_write_name (debug.c:2378)
==535033==    by 0x19C9A8: debug_write (debug.c:2350)
==535033==    by 0x19802D: print_debugging_info (prdbg.c:296)
==535033==    by 0x16A6F9: dump_bfd (objdump.c:5693)
==535033==    by 0x16B43C: display_object_bfd (objdump.c:5744)
==535033==    by 0x16B43C: display_any_bfd (objdump.c:5831)
==535033==    by 0x16B4F2: display_file (objdump.c:5852)
==535033==    by 0x16B4F2: display_file (objdump.c:5835)
==535033==    by 0x165C17: main (objdump.c:6263)
==535033==
==535033== Use of uninitialised value of size 8
==535033==    at 0x48BB33B: _itoa_word (_itoa.c:177)
==535033==    by 0x48D6B3D: __vfprintf_internal (vfprintf-internal.c:1516)
==535033==    by 0x48E2A08: __vsprintf_internal (iovsprintf.c:95)
==535033==    by 0x4995BE0: __sprintf_chk (sprintf_chk.c:40)
==535033==    by 0x197750: sprintf (stdio2.h:38)
==535033==    by 0x197750: print_vma (prdbg.c:484)
==535033==    by 0x197750: pr_struct_field (prdbg.c:1120)
==535033==    by 0x197750: pr_struct_field (prdbg.c:1105)
==535033==    by 0x199C2B: debug_write_type (debug.c:2541)
==535033==    by 0x19A57E: debug_write_name (debug.c:2378)
==535033==    by 0x19C9A8: debug_write (debug.c:2350)
==535033==    by 0x19802D: print_debugging_info (prdbg.c:296)
==535033==    by 0x16A6F9: dump_bfd (objdump.c:5693)
==535033==    by 0x16B43C: display_object_bfd (objdump.c:5744)
==535033==    by 0x16B43C: display_any_bfd (objdump.c:5831)
==535033==    by 0x16B4F2: display_file (objdump.c:5852)
==535033==    by 0x16B4F2: display_file (objdump.c:5835)
==535033==
==535033== Conditional jump or move depends on uninitialised value(s)
==535033==    at 0x48BB34C: _itoa_word (_itoa.c:177)
==535033==    by 0x48D6B3D: __vfprintf_internal (vfprintf-internal.c:1516)
==535033==    by 0x48E2A08: __vsprintf_internal (iovsprintf.c:95)
==535033==    by 0x4995BE0: __sprintf_chk (sprintf_chk.c:40)
==535033==    by 0x197750: sprintf (stdio2.h:38)
==535033==    by 0x197750: print_vma (prdbg.c:484)
==535033==    by 0x197750: pr_struct_field (prdbg.c:1120)
==535033==    by 0x197750: pr_struct_field (prdbg.c:1105)
==535033==    by 0x199C2B: debug_write_type (debug.c:2541)
==535033==    by 0x19A57E: debug_write_name (debug.c:2378)
==535033==    by 0x19C9A8: debug_write (debug.c:2350)
==535033==    by 0x19802D: print_debugging_info (prdbg.c:296)
==535033==    by 0x16A6F9: dump_bfd (objdump.c:5693)
==535033==    by 0x16B43C: display_object_bfd (objdump.c:5744)
==535033==    by 0x16B43C: display_any_bfd (objdump.c:5831)
==535033==    by 0x16B4F2: display_file (objdump.c:5852)
==535033==    by 0x16B4F2: display_file (objdump.c:5835)
==535033==
==535033== Conditional jump or move depends on uninitialised value(s)
==535033==    at 0x48D7643: __vfprintf_internal (vfprintf-internal.c:1516)
==535033==    by 0x48E2A08: __vsprintf_internal (iovsprintf.c:95)
==535033==    by 0x4995BE0: __sprintf_chk (sprintf_chk.c:40)
==535033==    by 0x197750: sprintf (stdio2.h:38)
==535033==    by 0x197750: print_vma (prdbg.c:484)
==535033==    by 0x197750: pr_struct_field (prdbg.c:1120)
==535033==    by 0x197750: pr_struct_field (prdbg.c:1105)
==535033==    by 0x199C2B: debug_write_type (debug.c:2541)
==535033==    by 0x19A57E: debug_write_name (debug.c:2378)
==535033==    by 0x19C9A8: debug_write (debug.c:2350)
==535033==    by 0x19802D: print_debugging_info (prdbg.c:296)
==535033==    by 0x16A6F9: dump_bfd (objdump.c:5693)
==535033==    by 0x16B43C: display_object_bfd (objdump.c:5744)
==535033==    by 0x16B43C: display_any_bfd (objdump.c:5831)
==535033==    by 0x16B4F2: display_file (objdump.c:5852)
==535033==    by 0x16B4F2: display_file (objdump.c:5835)
==535033==    by 0x165C17: main (objdump.c:6263)
==535033==
==535033== Conditional jump or move depends on uninitialised value(s)
==535033==    at 0x48D6C85: __vfprintf_internal (vfprintf-internal.c:1516)
==535033==    by 0x48E2A08: __vsprintf_internal (iovsprintf.c:95)
==535033==    by 0x4995BE0: __sprintf_chk (sprintf_chk.c:40)
==535033==    by 0x197750: sprintf (stdio2.h:38)
==535033==    by 0x197750: print_vma (prdbg.c:484)
==535033==    by 0x197750: pr_struct_field (prdbg.c:1120)
==535033==    by 0x197750: pr_struct_field (prdbg.c:1105)
==535033==    by 0x199C2B: debug_write_type (debug.c:2541)
==535033==    by 0x19A57E: debug_write_name (debug.c:2378)
==535033==    by 0x19C9A8: debug_write (debug.c:2350)
==535033==    by 0x19802D: print_debugging_info (prdbg.c:296)
==535033==    by 0x16A6F9: dump_bfd (objdump.c:5693)
==535033==    by 0x16B43C: display_object_bfd (objdump.c:5744)
==535033==    by 0x16B43C: display_any_bfd (objdump.c:5831)
==535033==    by 0x16B4F2: display_file (objdump.c:5852)
==535033==    by 0x16B4F2: display_file (objdump.c:5835)
==535033==    by 0x165C17: main (objdump.c:6263)
==535033==
<See attached full logs>
```

System environment:

```
[afl++ amdsuplus3] /work/tmpfs # gcc --version
gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[afl++ amdsuplus3] /work/tmpfs # g++ --version
g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[afl++ amdsuplus3] /work/tmpfs # cat /etc/issue
Ubuntu 22.04.2 LTS \n \l

[afl++ amdsuplus3] /work/tmpfs # uname -a
Linux amdsuplus3.inf.ethz.ch 5.4.0-146-generic #163-Ubuntu SMP Fri Mar 17 18:26:02 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
[afl++ amdsuplus3] /work/tmpfs #
```
Comment 1 Alan Modra 2023-04-18 00:49:51 UTC
*** Bug 30366 has been marked as a duplicate of this bug. ***
Comment 2 Sourceware Commits 2023-04-18 01:50:19 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=341eba4f9d4f39c8bd08ff59120662e86a3de305

commit 341eba4f9d4f39c8bd08ff59120662e86a3de305
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Apr 18 10:22:08 2023 +0930

    objdump use of uninitialised value in pr_string_field
    
            PR 30365
            * rdcoff.c (parse_coff_struct_type): Leave bitsize zero when no
            auxents.
Comment 3 Alan Modra 2023-04-18 01:51:03 UTC
Fixed