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/30322] New: gdb memory leak
Date: Fri, 07 Apr 2023 07:46:28 +0000	[thread overview]
Message-ID: <bug-30322-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 30322
           Summary: gdb memory leak
           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: ---

I found a memory leak bug in gdb.
Please confirm.
Thanks!



### Test Environment
Ubuntu 20.04, 64 bit binutils (version: v13.1 ;master)

### How to trigger
Compile the program with AddressSanitizer
Run command 
$ touch utils.o
$ touch aaa
$ mkdir dir
$ touch core.357036
$ ./gdb --cd=dir/ --se=utils.o --core=core.357036 --exec=./aaa --pid=1680
--symbols=utils.o

### Details
ASAN report
$./gdb --cd=dir/ --se=utils.o --core=core.357036 --exec=./aaa --pid=1680
--symbols=utils.o 
```
warning: Found custom handler for signal 7 (Bus error) preinstalled.
warning: Found custom handler for signal 8 (Floating point exception)
preinstalled.
warning: Found custom handler for signal 11 (Segmentation fault) preinstalled.
warning: Found custom handler for signal 15 (Terminated) preinstalled.
Some signal dispositions inherited from the environment (SIG_DFL/SIG_IGN)
won't be propagated to spawned programs.
GNU gdb (GDB) 13.0.50.20220805-git
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
./aaa: No such file or directory.
utils.o: No such file or directory.
Can't attach to process and specify a core file at the same time.

=================================================================
==2012456==ERROR: LeakSanitizer: detected memory leaks

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

Direct leak of 52 byte(s) in 1 object(s) allocated from:
    #0 0x4b0963 in __interceptor_realloc
(/home/cmd/lengthFuzz/binutils/gdb/gdb_cd_se_c_e_p_s/gdb+0x4b0963)
    #1 0x7f7aeceea077 in getcwd
/build/glibc-SzIz7B/glibc-2.31/io/../sysdeps/unix/sysv/linux/getcwd.c:84:8

Direct leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x4e242d in operator new(unsigned long)
(/home/cmd/lengthFuzz/binutils/gdb/gdb_cd_se_c_e_p_s/gdb+0x4e242d)
    #1 0x1dea176 in ui::ui(_IO_FILE*, _IO_FILE*, _IO_FILE*)
/home/cmd/FuzzDateset/binutils/binutils-gdb-binutils-2_39/gdb/top.c:315:19
    #2 0x15bec8b in captured_main_1(captured_main_args*)
/home/cmd/FuzzDateset/binutils/binutils-gdb-binutils-2_39/gdb/main.c:676:17
    #3 0x15be28d in captured_main(void*)
/home/cmd/FuzzDateset/binutils/binutils-gdb-binutils-2_39/gdb/main.c:1319:3
    #4 0x15be058 in gdb_main(captured_main_args*)
/home/cmd/FuzzDateset/binutils/binutils-gdb-binutils-2_39/gdb/main.c:1344:7
    #5 0x4e4f12 in main
/home/cmd/FuzzDateset/binutils/binutils-gdb-binutils-2_39/gdb/gdb.c:32:10
    #6 0x7f7aecdff082 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/lengthFuzz/binutils/gdb/gdb_cd_se_c_e_p_s/gdb+0x4e242d)
    #1 0x1de9fc1 in ui::ui(_IO_FILE*, _IO_FILE*, _IO_FILE*)
/home/cmd/FuzzDateset/binutils/binutils-gdb-binutils-2_39/gdb/top.c:313:35
    #2 0x15bec8b in captured_main_1(captured_main_args*)
/home/cmd/FuzzDateset/binutils/binutils-gdb-binutils-2_39/gdb/main.c:676:17
    #3 0x15be28d in captured_main(void*)
/home/cmd/FuzzDateset/binutils/binutils-gdb-binutils-2_39/gdb/main.c:1319:3
    #4 0x15be058 in gdb_main(captured_main_args*)
/home/cmd/FuzzDateset/binutils/binutils-gdb-binutils-2_39/gdb/main.c:1344:7
    #5 0x4e4f12 in main
/home/cmd/FuzzDateset/binutils/binutils-gdb-binutils-2_39/gdb/gdb.c:32:10
    #6 0x7f7aecdff082 in __libc_start_main
/build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: 260 byte(s) leaked in 4 allocation(s).
```

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

             reply	other threads:[~2023-04-07  7:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-07  7:46 mengda2020 at iscas dot ac.cn [this message]
2023-04-07 19:10 ` [Bug gdb/30322] " tromey at sourceware dot org
2023-06-01 13:30 ` tromey at sourceware dot org
2023-06-09 20:02 ` 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-30322-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).