anfedorov / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

OS X: mapped memory regions report incorrect file name #394

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In _psutil_osx.c get_process_memory_maps() (see #260) the file names are off by 
one line.

I think the proc_regionfilename() should be called with the base address of a 
region, not with address+size: 
https://code.google.com/p/psutil/source/browse/psutil/_psutil_osx.c?spec=svn5787
00e9906f2e92ef76a56dabf3ed7d7a9740c2&r=578700e9906f2e92ef76a56dabf3ed7d7a9740c2#
346

This is OS X 10.7 (Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; 
root:xnu-1699.32.7~1/RELEASE_X86_64):

$ sudo python examples/pmap.py 60271
00000000033a1000         4K  r--/rwx [prv]
0000000003400000        12K  rw-/rwx /Users/...
0000000003500000    100000K  r--/r-x /Users/...

$ vmmap -v 60271
MALLOC metadata        00000001033a1000-00000001033a2000 [    4K     4K     4K] 
r--/rwx SM=COW
MALLOC_TINY            0000000103400000-0000000103500000 [ 1024K    12K    12K] 
rw-/rwx SM=COW          DefaultMallocZone_0x103371000
mapped file            0000000103500000-00000001096a8000 [ 97.7M  97.7M     0K] 
r--/r-x SM=S/A          /Users/...

Original issue reported on code.google.com by asqueella on 17 Jun 2013 at 11:11

GoogleCodeExporter commented 8 years ago
Thanks for the report looks like that may be correct... arguments to 
proc_regionfilename() should be

proc_regionfilename(
  int pid, 
  uint64_t address,
  void *buffer,
  uint32_t buffersize
);

I think the address += size is meant to be incrementing to the next memory map 
but it's happening before the first call to proc_regionfilename() and throwing 
everything off by one. 

Original comment by jlo...@gmail.com on 17 Jun 2013 at 11:35

GoogleCodeExporter commented 8 years ago
Checked in as part of revision 825b10935cc0

Original comment by jlo...@gmail.com on 18 Jun 2013 at 12:15

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 11 Jul 2013 at 8:54