baweaver / psutil

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

Process get_memory_maps() raises RuntimeError on BSD #366

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
>>> import psutil
>>> psutil.Process(1).get_memory_maps()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "psutil/__init__.py", line 655, in get_memory_maps
    it = self._platform_impl.get_memory_maps()
  File "psutil/_psbsd.py", line 152, in wrapper
    return fun(self, *args, **kwargs)
  File "psutil/_psbsd.py", line 338, in get_memory_maps
    return _psutil_bsd.get_process_memory_maps(self.pid)
RuntimeError: kinfo_getvmmap() failed

This happens for all low-pid processes.
Instead we should raise AccessDenied.

Original issue reported on code.google.com by g.rodola on 11 Apr 2013 at 1:32

GoogleCodeExporter commented 8 years ago
Actually it's not just get_memory_maps().
We also have:
- get_num_fds()
- get_open_files()
- getcwd()

All of them should raise AccessDenied.

    ======================================================================
    FAIL: test_get_memory_maps (proc=psutil.Process(pid=0, name='kernel'))
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test/test_psutil.py", line 1717, in test_fetch_all
        ret = attr()
      File "build/bdist.freebsd-9.1-RC1-amd64/egg/psutil/__init__.py", line 655, in get_memory_maps
        it = self._platform_impl.get_memory_maps()
      File "build/bdist.freebsd-9.1-RC1-amd64/egg/psutil/_psbsd.py", line 152, in wrapper
        return fun(self, *args, **kwargs)
      File "build/bdist.freebsd-9.1-RC1-amd64/egg/psutil/_psbsd.py", line 338, in get_memory_maps
        return _psutil_bsd.get_process_memory_maps(self.pid)
    RuntimeError: kinfo_getvmmap() failed    

    ======================================================================
    FAIL: test_get_num_fds (proc=psutil.Process(pid=0, name='kernel'))
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test/test_psutil.py", line 1717, in test_fetch_all
        ret = attr()
      File "build/bdist.freebsd-9.1-RC1-amd64/egg/psutil/__init__.py", line 463, in get_num_fds
        return self._platform_impl.get_num_fds()
      File "build/bdist.freebsd-9.1-RC1-amd64/egg/psutil/_psbsd.py", line 152, in wrapper
        return fun(self, *args, **kwargs)
      File "build/bdist.freebsd-9.1-RC1-amd64/egg/psutil/_psbsd.py", line 268, in get_num_fds
        return _psutil_bsd.get_process_num_fds(self.pid)
    SystemError: error return without exception set    

    ======================================================================
    FAIL: test_get_open_files (proc=psutil.Process(pid=0, name='kernel'))
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test/test_psutil.py", line 1717, in test_fetch_all
        ret = attr()
      File "build/bdist.freebsd-9.1-RC1-amd64/egg/psutil/__init__.py", line 675, in get_open_files
        return self._platform_impl.get_open_files()
      File "build/bdist.freebsd-9.1-RC1-amd64/egg/psutil/_psbsd.py", line 152, in wrapper
        return fun(self, *args, **kwargs)
      File "build/bdist.freebsd-9.1-RC1-amd64/egg/psutil/_psbsd.py", line 286, in get_open_files
        rawlist = _psutil_bsd.get_process_open_files(self.pid)
    SystemError: error return without exception set    

    ======================================================================
    FAIL: test_getcwd (proc=psutil.Process(pid=0, name='kernel'))
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test/test_psutil.py", line 1717, in test_fetch_all
        ret = attr()
      File "build/bdist.freebsd-9.1-RC1-amd64/egg/psutil/__init__.py", line 385, in getcwd
        return self._platform_impl.get_process_cwd()
      File "build/bdist.freebsd-9.1-RC1-amd64/egg/psutil/_psbsd.py", line 152, in wrapper
        return fun(self, *args, **kwargs)
      File "build/bdist.freebsd-9.1-RC1-amd64/egg/psutil/_psbsd.py", line 218, in get_process_cwd
        return _psutil_bsd.get_process_cwd(self.pid) or None
    SystemError: error return without exception set

Original comment by g.rodola on 11 Apr 2013 at 2:52

GoogleCodeExporter commented 8 years ago
Fixed in revision f976a68910c2.

Original comment by g.rodola on 11 Apr 2013 at 10:43

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 11 Apr 2013 at 10:43

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 12 Apr 2013 at 6:21