gdb-heap icon indicating copy to clipboard operation
gdb-heap copied to clipboard

There is no member named size

Open aspin opened this issue 6 years ago • 7 comments

Hi, not sure if this project is being maintained anymore, but looking for some tips (I'm not that experiences with GDB but trying to diagnose a memory leak). Getting this error when running the program:

(gdb) set python print-stack full
(gdb) heap
Traceback (most recent call last):
  File "/app/gdb-heap/heap/commands.py", line 34, in g
    return f(self, args, from_tty)
  File "/app/gdb-heap/heap/commands.py", line 56, in invoke
    usage_list = list(lazily_get_usage_list())
  File "/app/gdb-heap/heap/__init__.py", line 502, in lazily_get_usage_list
    usage_list = list(iter_usage_with_progress())
  File "/app/gdb-heap/heap/__init__.py", line 612, in __next__
    return self.inner.__next__()
  File "/app/gdb-heap/heap/__init__.py", line 677, in iter_usage
    chunksize = chunk.chunksize()
  File "/app/gdb-heap/heap/glibc.py", line 75, in chunksize
    return self.size() & ~(self.SIZE_BITS)
  File "/app/gdb-heap/heap/glibc.py", line 71, in size
    self._cached_size = int(self.field('size'))
  File "/app/gdb-heap/heap/__init__.py", line 117, in field
    return self._gdbval[attr]
gdb.error: There is no member named size.
Error occurred in Python command: There is no member named size.

If it helps, using python3.7-dbg for all of this, running inside a Docker container.

aspin avatar Jul 02 '19 21:07 aspin

Found the solution –– whatever versions I'm running there's a mismatch in some fields. It's now mchunk_size and mchunk_prev_size instead of size and prev_size.

aspin avatar Jul 02 '19 22:07 aspin

Great! Can you submit a patch? Is this an update in libc? What Linux version/flavor?

rogerhu avatar Jul 02 '19 22:07 rogerhu

I'm running this in the Python Docker container with tag 3.8-rc,.

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

I'm not quite sure the correct library, but here's a small dump of what I have:

$ apt list --installed | grep libc

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libc-bin/testing,now 2.28-10 amd64 [installed,automatic]
libc-dev-bin/testing,now 2.28-10 amd64 [installed,automatic]
libc6-dbg/testing,now 2.28-10 amd64 [installed]
libc6-dev/testing,now 2.28-10 amd64 [installed]
[rest look irrelevant]

Also, I installed ibglib2.0-dev instead of libglib2.0-0-dbg (I'm not super familiar with figuring out package repos I can add so I just tried the other one when libglib2.0-0-dbg couldn't be found), which I think brought in libglib2.0-dev.

Happy to submit a patch, but how would you want this implemented? Don't want to break for other people if this currently still works

aspin avatar Jul 03 '19 15:07 aspin

Also, the heap dump is struggling to categorized memory allocations correctly for me –– still looking into that. I'm using python3.7-dbg –– looks like a lot of the existing code was written for Python 2, maybe some stuff has changed since then?

aspin avatar Jul 03 '19 15:07 aspin

Something likely changed with libc and/or the glib2. The code originally was written in Python 2 but I thought we fixed the issues after Python 3 got used. Best way to check might be booting up older containers of Ubuntu

rogerhu avatar Jul 03 '19 15:07 rogerhu

I getting errors:

Python Exception <class 'gdb.error'> There is no member named str. 
Python Exception <class 'gdb.error'> There is no member named ma_table.

After change heap/cpython.py:L280 from m_str = int(self.field('str')) to m_str = int(self.field('data').address), the str error seems fixed. See also https://github.com/python/cpython/blob/3.6/Tools/gdb/libpython.py#L1184 .

But I don't known how to fix no member named ma_table, can anyone give me some guides to fix similar problems?

My system information:

  • GNU gdb (Ubuntu 8.1-0ubuntu3.1) 8.1.0.20180409-git
  • Python 3.6.8
  • Ubuntu 18.04.1 LTS

guyskk avatar Oct 09 '19 16:10 guyskk

I worked around these here: https://github.com/edmcman/gdb-heap

My changes aren't complete, but they are enough to avoid crashing at least

edmcman avatar Aug 20 '21 14:08 edmcman