public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "mengda2020 at iscas dot ac.cn" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/30504] New: Memory Leak in ui::ui in top.c:313
Date: Thu, 01 Jun 2023 07:27:03 +0000	[thread overview]
Message-ID: <bug-30504-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=30504

            Bug ID: 30504
           Summary: Memory Leak in ui::ui in top.c:313
           Product: gdb
           Version: 13.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: mengda2020 at iscas dot ac.cn
  Target Milestone: ---

Memory leaks occur when run gdb.

# Test Environment

Ubuntu 20.04, 64 bit
version 13.1

# Reproduce steps

1. compile gdb with ASAN
```
$ CFLAGS="-g -O0 -fsanitize=address" CXXFLAGS="-g -O0 -fsanitize=address"
./configure --prefix=`pwd`/install
$ make
```
2. run cmd.(as is only a binary, its content is not important)
```
$ ./gdb --batch-silent as
```

# ASAN report

```
Direct leak of 112 byte(s) in 1 object(s) allocated from:
    #0 0x4e242d in operator new(unsigned long)
(/home/cmd/sp/Dataset/Binutils/binutils_aflpp/install/bin/gdb+0x4e242d)
    #1 0x1de9fa6 in ui::ui(_IO_FILE*, _IO_FILE*, _IO_FILE*)
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/top.c:313:19
    #2 0x15bec8b in captured_main_1(captured_main_args*)
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/main.c:676:17
    #3 0x15be28d in captured_main(void*)
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/main.c:1319:3
    #4 0x15be058 in gdb_main(captured_main_args*)
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/main.c:1344:7
    #5 0x4e4f12 in main
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/gdb.c:32:10
    #6 0x7f53b7f14082 in __libc_start_main
/build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16

Direct leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x4e242d in operator new(unsigned long)
(/home/cmd/sp/Dataset/Binutils/binutils_aflpp/install/bin/gdb+0x4e242d)
    #1 0x1dea176 in ui::ui(_IO_FILE*, _IO_FILE*, _IO_FILE*)
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/top.c:315:19
    #2 0x15bec8b in captured_main_1(captured_main_args*)
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/main.c:676:17
    #3 0x15be28d in captured_main(void*)
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/main.c:1319:3
    #4 0x15be058 in gdb_main(captured_main_args*)
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/main.c:1344:7
    #5 0x4e4f12 in main
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/gdb.c:32:10
    #6 0x7f53b7f14082 in __libc_start_main
/build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16

Indirect leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x4e242d in operator new(unsigned long)
(/home/cmd/sp/Dataset/Binutils/binutils_aflpp/install/bin/gdb+0x4e242d)
    #1 0x1de9fc1 in ui::ui(_IO_FILE*, _IO_FILE*, _IO_FILE*)
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/top.c:313:35
    #2 0x15bec8b in captured_main_1(captured_main_args*)
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/main.c:676:17
    #3 0x15be28d in captured_main(void*)
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/main.c:1319:3
    #4 0x15be058 in gdb_main(captured_main_args*)
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/main.c:1344:7
    #5 0x4e4f12 in main
/home/cmd/sp/Dataset/Binutils/binutils_aflpp/gdb/gdb.c:32:10
    #6 0x7f53b7f14082 in __libc_start_main
/build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: 208 byte(s) leaked in 3 allocation(s).
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2023-06-01  7:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01  7:27 mengda2020 at iscas dot ac.cn [this message]
2023-06-01 13:30 ` [Bug gdb/30504] " tromey at sourceware dot 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-30504-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.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).