yanqi27 / core_analyzer

A power tool to debug memory-related issues
376 stars 72 forks source link

I have installed libc6-dbg,“(gdb) heap Failed to extract heap metadata from gv mp_ == The memory manager is assumed to be glibc 2.31 == == If this is not true, please debug with another machine with matching glibc == #70

Closed liuhangyu closed 2 years ago

liuhangyu commented 2 years ago

failed to init heap command

” 1. dpkg -s libc6-dbg Package: libc6-dbg Status: install ok installed Priority: optional Section: debug Installed-Size: 29293 Maintainer: Ubuntu Developers ubuntu-devel-discuss@lists.ubuntu.com Architecture: amd64 Multi-Arch: same Source: glibc Version: 2.31-0ubuntu9.9 Provides: libc-dbg Depends: libc6 (= 2.31-0ubuntu9.9) Description: GNU C Library: detached debugging symbols This package contains the detached debugging symbols for the GNU C library. Homepage: https://www.gnu.org/software/libc/libc.html Build-Ids: 00329f3d85e153a01672b77b853beda0faf0dee6 00c4ae3a65bc87ea96986b3b2441e892c8a433f0 00cd9124f765fe93560701d55d5c61c37be4657a 01177dee353e3e44244586eed35b15f161a63908 03505bbb2b0381d376b10ba11b0d82f36a29155d 03c1af6b8e962c17f07c5bea32165949660247d7 03f2e8478015abbd5470fef1563891e73f50feb3 05843abad5bc67a085e946f5ec426432fadf9086 05c14e24b1b2c812a1562ccd088eb0c1aaefe986 06f472d792b9657763598d176e803e33b310df2d 07c3def9d91e67555518771f0ab9c4f7d8b4c5f5 08a4b38da60fb6b41e3d10eb8627d08d8185f12a 094e706d84e9825d421496d5a7ce130ee8277ec4 097e37c0bea103373b3741b8bdca0772e6cfecf6 0c0e2959ab6a676c25d954521955902933e940c0 0cbc03e1cdf23ebd100ec83a8bf024a40210c1ce 0cd7222ce7ccb36bd00574b88e763beb2d71f4d1 0e6d0cbb2d401ec427997c2c3bec0cc461e4801d 0e82e05bb8a77614e55d4e94a3a111acdedf99d8 0ebd68a83bda746684483d7c63958c5b42be1c6b 0f55867a69716900ba6b7a3e43a350a912a74b68 10ec8356b1c7ec55f7b297dbeb40e83d64ab8292 11bd9fe7778d95a0dd93124f416754137c9b097c 121e85d062973da7e3f0736bfb2bb2d30f4a8d5d 12ca5ba6012d816eec6b6add4d23b883f2b830e3 1326af6014e3796af39155a836a0886843d1097b 13316643db72f54092be4ed62327bba6a12054fa 1355e78564f5c0fb3dd0e6fa9170250932d57346 1369b9a1a0ed2dfab09490bca78eb250fc234b2c 141b9f727e7e8afb2190e46521d4b99009bfb040 14c0ed437f22045a47de6669a2287bd4defb543

.gdbinit set debug-file-directory /usr/lib/debug

./a.out core-a.out-54759-1665391675 --data-directory=/usr/local/gdb12/share/gdb GNU gdb (GDB) 12.1 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"... Reading symbols from ./a.out...

warning: exec file is newer than core file. [New LWP 54759] Core was generated by `./a.out'. Program terminated with signal SIGSEGV, Segmentation fault.

0 0x000056016c2fa161 in main () at t1.c:6

6 *p = 1; (gdb) bt

0 0x000056016c2fa161 in main () at t1.c:6

(gdb) heap Failed to extract heap metadata from gv mp_ == The memory manager is assumed to be glibc 2.31 == == If this is not true, please debug with another machine with matching glibc == failed to init heap (gdb)

liuhangyu commented 2 years ago

have installed libc6-dbg and configured set debug-file-directory /usr/lib/debug, but Failed to extract heap metadata from gv mp_ still appears

Celthi commented 2 years ago

Please type info shared in the gdb and see if the libc so has the correct debug symbol loaded.

liuhangyu commented 2 years ago

gdb ./a.out core-a.out-8023-1665712009 --data-directory=/usr/local/gdb12/share/gdb GNU gdb (GDB) 12.1 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"... Reading symbols from ./a.out... [New LWP 8023] Core was generated by `./a.out'. Program terminated with signal SIGSEGV, Segmentation fault.

0 0x00005568cf903161 in main () at t1.c:6

6 *p = 1; (gdb) bt

0 0x00005568cf903161 in main () at t1.c:6

(gdb) info shared From To Syms Read Shared Object Library 0x00007fed4d305630 0x00007fed4d47a27d Yes /lib/x86_64-linux-gnu/libc.so.6 0x00007fed4d4f5100 0x00007fed4d517684 Yes /lib64/ld-linux-x86-64.so.2 (gdb)

Celthi commented 2 years ago

It looks like you're doing the test. Is it code too simple that does not allocate any heap data?

liuhangyu commented 2 years ago

(gdb) info auto-load gdb-scripts: No auto-load scripts. libthread-db: No auto-loaded libthread-db. local-gdbinit: Local .gdbinit file was not found. python-scripts: No auto-load scripts. (gdb)

liuhangyu commented 2 years ago

liuhy@t480:~/learning/c-test/gdb_core$ gdb --configuration This GDB was configured as follows: configure --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --with-auto-load-dir=$debugdir:$datadir/auto-load --with-auto-load-safe-path=$debugdir:$datadir/auto-load --with-expat --with-gdb-datadir=/usr/local/gdb12/share/gdb (relocatable) --with-jit-reader-dir=/usr/local/gdb12/lib/gdb (relocatable) --without-libunwind-ia64 --with-lzma --without-babeltrace --without-intel-pt --with-mpfr --without-xxhash --with-python=/usr --with-python-libdir=/usr/lib --without-debuginfod --without-guile --disable-source-highlight --with-separate-debug-dir=/usr/local/gdb12/lib/debug (relocatable) --with-system-gdbinit=/usr/local/gdb12/etc/gdbinit (relocatable)

("Relocatable" means the directory can be moved with the GDB installation tree, and GDB will still find it.)

liuhangyu commented 2 years ago

It looks like you're doing the test. Is it code too simple that does not allocate any heap data?

Thank you Maybe that's why

liuhangyu commented 2 years ago

t1.c gdb:

gdb ./a.out GNU gdb (GDB) 12.1 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"... Reading symbols from ./a.out... (gdb) b main Breakpoint 1 at 0x1195: file t1.c, line 6. (gdb) n The program is not being run. (gdb) r Starting program: /home/liuhy/learning/c-test/gdb_core/a.out

Breakpoint 1, main () at t1.c:6 6 int p = (int)malloc(sizeof(int) * 2); (gdb) n 7 memcpy(p, "1234567890", 10); (gdb) n 8 printf("bad\n"); (gdb) heap Failed to evaluate thread-local variable "tcache": Cannot find thread-local storage for process 118144, shared library /lib/x86_64-linux-gnu/libc.so.6: Cannot find thread-local variables on this target Tuning params & stats: mmap_threshold=131072 pagesize=4096 n_mmaps=0 n_mmaps_max=65536 total mmap regions created=0 mmapped_mem=0 sbrk_base=0x555555559000 Main arena (0x7ffff7fa6b80) owns regions: [0x555555559010 - 0x55555557a000] Total 131KB in-use 2(672) free 1(131KB)

There are 1 arenas Total 131KB
Total 2 blocks in-use of 672
Total 1 blocks free of 131KB

(gdb)

liuhangyu commented 2 years ago

cat t1.c

include

include

include

int main() { int p = (int)malloc(sizeof(int) * 2); memcpy(p, "1234567890", 10); printf("bad\n"); return 0; }

Celthi commented 2 years ago

Close as it is not an issue.

liuhangyu commented 2 years ago

think you