public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30176] New: Memory Leak in xmalloc at alloc.c:57
@ 2023-02-27  3:09 mengda2020 at iscas dot ac.cn
  2023-02-27 14:50 ` [Bug gdb/30176] " tromey at sourceware dot org
  0 siblings, 1 reply; 2+ messages in thread
From: mengda2020 at iscas dot ac.cn @ 2023-02-27  3:09 UTC (permalink / raw)
  To: gdb-prs

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug gdb/30176] Memory Leak in xmalloc at alloc.c:57
  2023-02-27  3:09 [Bug gdb/30176] New: Memory Leak in xmalloc at alloc.c:57 mengda2020 at iscas dot ac.cn
@ 2023-02-27 14:50 ` tromey at sourceware dot org
  0 siblings, 0 replies; 2+ messages in thread
From: tromey at sourceware dot org @ 2023-02-27 14:50 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
Some leaks are intentional, and some of these actually come
from Python.  I think you have to be a bit more selective
in your report.

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-27 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-27  3:09 [Bug gdb/30176] New: Memory Leak in xmalloc at alloc.c:57 mengda2020 at iscas dot ac.cn
2023-02-27 14:50 ` [Bug gdb/30176] " tromey at sourceware dot org

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).