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/30176] New: Memory Leak in xmalloc at alloc.c:57
Date: Mon, 27 Feb 2023 03:09:05 +0000	[thread overview]
Message-ID: <bug-30176-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 30176
           Summary: Memory Leak in xmalloc at alloc.c:57
           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

```
=================================================================
==920541==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 327793 byte(s) in 156 object(s) allocated from:
    #0 0x7f3a26b5c808 in __interceptor_malloc
../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f3a266e99e7  (/lib/x86_64-linux-gnu/libpython3.8.so.1.0+0x25a9e7)

Direct leak of 11234 byte(s) in 1179 object(s) allocated from:
    #0 0x7f3a26b5c808 in __interceptor_malloc
../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x56508ef54722 in xmalloc
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/alloc.c:57
    #2 0x5650903379e9 in xstrdup xstrdup.c:34
    #3 0x56508f184f51 in find_charset_names
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/charset.c:886
    #4 0x56508f18572c in _initialize_charset()
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/charset.c:992
    #5 0x56508ff5bedf in initialize_all_files()
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/init.c:368
    #6 0x56508fdd5d1d in gdb_init()
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/top.c:2409
    #7 0x56508f82a6db in captured_main_1
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/main.c:1023
    #8 0x56508f82c48f in captured_main
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/main.c:1320
    #9 0x56508f82c530 in gdb_main(captured_main_args*)
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/main.c:1345
    #10 0x56508ee55eb1 in main
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/gdb.c:32
    #11 0x7f3a25dac082 in __libc_start_main ../csu/libc-start.c:308

Direct leak of 1080 byte(s) in 2 object(s) allocated from:
    #0 0x7f3a26b5c808 in __interceptor_malloc
../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f3a266e9182  (/lib/x86_64-linux-gnu/libpython3.8.so.1.0+0x25a182)

Direct leak of 864 byte(s) in 3 object(s) allocated from:
    #0 0x7f3a26b5e587 in operator new(unsigned long)
../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x56508f1affb3 in do_add_cmd cli/cli-decode.c:185
    #2 0x56508f1b06e7 in add_cmd(char const*, command_class, char const*,
cmd_list_element**) cli/cli-decode.c:236
    #3 0x56508fa0beff in cmdpy_init python/py-cmd.c:520
    #4 0x7f3a266ce0c0  (/lib/x86_64-linux-gnu/libpython3.8.so.1.0+0x23f0c0)

Direct leak of 112 byte(s) in 1 object(s) allocated from:
    #0 0x7f3a26b5e587 in operator new(unsigned long)
../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x56508fdca93a in ui::ui(_IO_FILE*, _IO_FILE*, _IO_FILE*)
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/top.c:305
    #2 0x56508f829263 in captured_main_1
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/main.c:676
    #3 0x56508f82c48f in captured_main
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/main.c:1320
    #4 0x56508f82c530 in gdb_main(captured_main_args*)
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/main.c:1345
    #5 0x56508ee55eb1 in main
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/gdb.c:32
    #6 0x7f3a25dac082 in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 73186 byte(s) in 80 object(s) allocated from:
    #0 0x7f3a26b5c808 in __interceptor_malloc
../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f3a266e99e7  (/lib/x86_64-linux-gnu/libpython3.8.so.1.0+0x25a9e7)

Indirect leak of 1698 byte(s) in 4 object(s) allocated from:
    #0 0x7f3a26b5c808 in __interceptor_malloc
../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x56508ef54722 in xmalloc
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/alloc.c:57
    #2 0x5650903379e9 in xstrdup xstrdup.c:34
    #3 0x56508faa3af4 in unicode_to_encoded_string python/py-utils.c:71
    #4 0x56508faa41c1 in python_string_to_host_string(_object*)
python/py-utils.c:147
    #5 0x56508fa0baf7 in cmdpy_init python/py-cmd.c:492
    #6 0x7f3a266ce0c0  (/lib/x86_64-linux-gnu/libpython3.8.so.1.0+0x23f0c0)

Indirect leak of 834 byte(s) in 1 object(s) allocated from:
    #0 0x7f3a26b5c808 in __interceptor_malloc
../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f3a266e9182  (/lib/x86_64-linux-gnu/libpython3.8.so.1.0+0x25a182)

Indirect leak of 288 byte(s) in 1 object(s) allocated from:
    #0 0x7f3a26b5e587 in operator new(unsigned long)
../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x56508f1affb3 in do_add_cmd cli/cli-decode.c:185
    #2 0x56508f1b06e7 in add_cmd(char const*, command_class, char const*,
cmd_list_element**) cli/cli-decode.c:236
    #3 0x56508fa0beff in cmdpy_init python/py-cmd.c:520
    #4 0x7f3a266ce0c0  (/lib/x86_64-linux-gnu/libpython3.8.so.1.0+0x23f0c0)

Indirect leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x7f3a26b5e587 in operator new(unsigned long)
../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x56508fdca8ee in ui::ui(_IO_FILE*, _IO_FILE*, _IO_FILE*)
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/top.c:305
    #2 0x56508f829263 in captured_main_1
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/main.c:676
    #3 0x56508f82c48f in captured_main
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/main.c:1320
    #4 0x56508f82c530 in gdb_main(captured_main_args*)
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/main.c:1345
    #5 0x56508ee55eb1 in main
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/gdb.c:32
    #6 0x7f3a25dac082 in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 29 byte(s) in 4 object(s) allocated from:
    #0 0x7f3a26b5c808 in __interceptor_malloc
../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x56508ef54722 in xmalloc
/home/cmd/gdb/binutils-gdb-gdb-13.1-release/gdb/alloc.c:57
    #2 0x56508fa0aefe in gdbpy_parse_command_name(char const*,
cmd_list_element***, cmd_list_element**) python/py-cmd.c:370
    #3 0x56508fa0b92c in cmdpy_init python/py-cmd.c:472
    #4 0x7f3a266ce0c0  (/lib/x86_64-linux-gnu/libpython3.8.so.1.0+0x23f0c0)

SUMMARY: AddressSanitizer: 417166 byte(s) leaked in 1432 allocation(s).
```

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

             reply	other threads:[~2023-02-27  3:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27  3:09 mengda2020 at iscas dot ac.cn [this message]
2023-02-27 14:50 ` [Bug gdb/30176] " 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-30176-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).