Closed fish2bird closed 1 year ago
The cost to rebuild the heap metadata is high though it is easy to code it with a single function call. The tool is not designed to debug a live process like stepping through code line by line.
There is a switch_heap
command. @fish2bird could you give it a try and see if it will work? I don't have a vivid memory for the command now.
There is a
switch_heap
command. @fish2bird could you give it a try and see if it will work? I don't have a vivid memory for the command now.
Thank you, twice-switch works!
(gdb) switch_heap
Please provide the heap manager name, currently supported heap managers: jemalloc, (current)pt 2.27, pt 2.28-2.31, pt 2.32-2.37, tc.
(gdb) switch_heap pt 2.27
switch to heap pt 2.27
(gdb) heap /v
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=0x555555771000
Main arena (0x7ffff779f6e0) owns regions:
[0x555555771010 - 0x555555792000] Total 131KB
Error: chunk at 0x54552e53555f6e65 in fastbin[0] is misaligned
Chunk address comes from previous fastbin chunk at 0x555555771000 with fd=0x54552e53555f6e65
1 Errors encountered while walking the heap!
[Error] Failed to walk heap
(gdb) switch_heap tc
switch to heap tc
Failed to lookup gv "kPageShift"
(gdb) switch_heap pt 2.27
switch to heap pt 2.27
(gdb) heap /v
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=0x555555771000
Main arena (0x7ffff779f6e0) owns regions:
[0x555555771010 - 0x555555792000] Total 131KB in-use 3(920) free 2(131KB)
There are 1 arenas Total 131KB
Total 3 blocks in-use of 920
Total 2 blocks free of 131KB
========== In-use Memory Histogram ==========
Size-Range Count Total-Bytes
16 - 32 1(33%) 24(2%)
64 - 128 1(33%) 120(13%)
512 - 1024 1(33%) 776(84%)
Total 3 920
========== Free Memory Histogram ==========
Size-Range Count Total-Bytes
512 - 1024 1(50%) 536(0%)
128KB - 256KB 1(50%) 130KB(99%)
Total 2 131KB
(gdb)
While I stepping my programming, core_analyzer walk failed util /proc/pid/maps changes. so I have to use gdb over gdb to hack linux_nat_find_memory_regions return false.
Step 1: re-walk heap failed after step throng some functions
Step2: use ANOTHER gdb to hijack linux_nat_find_memory_regions
step 3: now heap walk works.
Rebuild policy expect to be more smart or support manual.
Best regards.