Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process get_memory_maps() raises RuntimeError on BSD #366

Closed
giampaolo opened this issue May 23, 2014 · 4 comments
Closed

Process get_memory_maps() raises RuntimeError on BSD #366

giampaolo opened this issue May 23, 2014 · 4 comments

Comments

@giampaolo
Copy link
Owner

From g.rodola on April 11, 2013 15:32:09

>>> 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: http://code.google.com/p/psutil/issues/detail?id=366

@giampaolo giampaolo self-assigned this May 23, 2014
@giampaolo
Copy link
Owner Author

From g.rodola on April 11, 2013 07:52:42

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

Labels: -Priority-Medium Priority-High

@giampaolo
Copy link
Owner Author

From g.rodola on April 11, 2013 15:43:33

Fixed in revision f976a68910c2 .

@giampaolo
Copy link
Owner Author

From g.rodola on April 11, 2013 15:43:42

Status: FixedInHG

@giampaolo
Copy link
Owner Author

From g.rodola on April 12, 2013 11:21:27

Status: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant