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

psutil-5.4.7 fails tests on macOS #1333

Closed
kamischi opened this issue Sep 10, 2018 · 4 comments
Closed

psutil-5.4.7 fails tests on macOS #1333

kamischi opened this issue Sep 10, 2018 · 4 comments

Comments

@kamischi
Copy link

kamischi commented Sep 10, 2018

make tests fails on macOS with python 3.4, 3.5, 3.6, and 3.7:

... skip long output ... 
psutil.tests.test_windows.TestSystemAPIs.test_pids ... skipped 'WINDOWS only'
psutil.tests.test_windows.TestSystemAPIs.test_total_phymem ... skipped 'WINDOWS only'

======================================================================
ERROR: psutil.tests.test_unicode.TestFSAPIs.test_memory_maps
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/test_unicode.py", line 276, in test_memory_maps
    with copyload_shared_lib(dst_prefix=self.funky_name) as funky_path:
  File "/sw/lib/python3.5/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/__init__.py", line 1197, in copyload_shared_lib
    libs = [x.path for x in psutil.Process().memory_maps() if
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/__init__.py", line 1111, in memory_maps
    it = self._proc.memory_maps()
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/_psosx.py", line 335, in wrapper
    return fun(self, *args, **kwargs)
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/_psosx.py", line 576, in memory_maps
    return cext.proc_memory_maps(self.pid)
OSError: [Errno 22] Invalid argument

======================================================================
ERROR: setUpClass (psutil.tests.test_unicode.TestFSAPIsWithInvalidPath)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/test_unicode.py", line 149, in setUpClass
    create_exe(cls.funky_name)
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/__init__.py", line 783, in create_exe
    shutil.copyfile(PYTHON_EXE, outpath)
  File "/sw/lib/python3.5/shutil.py", line 121, in copyfile
    with open(dst, 'wb') as fdst:
OSError: [Errno 92] Illegal byte sequence: '/Users/michael/Downloads/psutil-5.4.7/@psutil-test-72120f\udcc0\udc80'

======================================================================
ERROR: psutil.tests.test_misc.TestMisc.test_process_as_dict_no_new_names
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/test_misc.py", line 210, in test_process_as_dict_no_new_names
    self.assertNotIn('foo', p.as_dict())
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/__init__.py", line 526, in as_dict
    ret = meth()
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/__init__.py", line 1111, in memory_maps
    it = self._proc.memory_maps()
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/_psosx.py", line 335, in wrapper
    return fun(self, *args, **kwargs)
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/_psosx.py", line 576, in memory_maps
    return cext.proc_memory_maps(self.pid)
OSError: [Errno 22] Invalid argument

======================================================================
ERROR: psutil.tests.test_misc.TestMisc.test_serialization
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/test_misc.py", line 352, in test_serialization
    check(psutil.Process().as_dict())
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/__init__.py", line 526, in as_dict
    ret = meth()
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/__init__.py", line 1111, in memory_maps
    it = self._proc.memory_maps()
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/_psosx.py", line 335, in wrapper
    return fun(self, *args, **kwargs)
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/_psosx.py", line 576, in memory_maps
    return cext.proc_memory_maps(self.pid)
OSError: [Errno 22] Invalid argument

======================================================================
ERROR: psutil.tests.test_posix.TestProcess.test_num_fds
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/test_posix.py", line 271, in test_num_fds
    call(p, name)
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/test_posix.py", line 251, in call
    attr(*args)
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/__init__.py", line 1111, in memory_maps
    it = self._proc.memory_maps()
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/_psosx.py", line 335, in wrapper
    return fun(self, *args, **kwargs)
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/_psosx.py", line 576, in memory_maps
    return cext.proc_memory_maps(self.pid)
OSError: [Errno 22] Invalid argument

======================================================================
ERROR: psutil.tests.test_process.TestProcess.test_memory_maps
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/test_process.py", line 615, in test_memory_maps
    maps = p.memory_maps()
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/__init__.py", line 1111, in memory_maps
    it = self._proc.memory_maps()
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/_psosx.py", line 335, in wrapper
    return fun(self, *args, **kwargs)
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/_psosx.py", line 576, in memory_maps
    return cext.proc_memory_maps(self.pid)
OSError: [Errno 22] Invalid argument

======================================================================
ERROR: psutil.tests.test_process.TestProcess.test_memory_maps_lists_lib
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/test_process.py", line 656, in test_memory_maps_lists_lib
    with copyload_shared_lib() as path:
  File "/sw/lib/python3.5/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/__init__.py", line 1197, in copyload_shared_lib
    libs = [x.path for x in psutil.Process().memory_maps() if
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/__init__.py", line 1111, in memory_maps
    it = self._proc.memory_maps()
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/_psosx.py", line 335, in wrapper
    return fun(self, *args, **kwargs)
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/_psosx.py", line 576, in memory_maps
    return cext.proc_memory_maps(self.pid)
OSError: [Errno 22] Invalid argument

======================================================================
FAIL: psutil.tests.test_contracts.TestFetchAllProcesses.test_fetch_all
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/test_contracts.py", line 355, in test_fetch_all
    meth(ret, p)
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/test_contracts.py", line 381, in exe
    assert os.access(ret, os.X_OK)
AssertionError

======================================================================
FAIL: psutil.tests.test_posix.TestProcess.test_name
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/test_posix.py", line 159, in test_name
    self.assertEqual(name_ps, name_psutil)
AssertionError: 'python' != 'pythonm'
- python
+ pythonm
?       +


======================================================================
FAIL: psutil.tests.test_system.TestSystemAPIs.test_cpu_times_time_increases
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/michael/Downloads/psutil-5.4.7/psutil/tests/test_system.py", line 325, in test_cpu_times_time_increases
    self.fail("difference %s" % difference)
AssertionError: difference 0.0

----------------------------------------------------------------------
Ran 518 tests in 21.425s

FAILED (failures=3, errors=7, skipped=241)
@giampaolo
Copy link
Owner

Sorry for the big delay in responding. I've seen this:

  File "/Users/michael/Downloads/psutil-5.4.7/psutil/_psosx.py", line 576, in memory_maps
    return cext.proc_memory_maps(self.pid)
OSError: [Errno 22] Invalid argument

...happening from time to time but I'm unable to reproduce it. Would you be able to put some printf()s in _psutil_osx.c to figure out where it's originating from? My guess is it's coming from here:

err = vm_region_recurse_64(task, &address, &size, &depth,

@comonadd
Copy link

comonadd commented Jan 20, 2019

Can confirm this. I am running OSX 10.14 and I can't run a single test. It also appears that the psutil.process_iter function, when run as a superuser, corrupts the memory of different random parts of my system, and, as a result, I get a lot of SEGFAULTS after that on all kinds of services/applications. Hope this will be fixed.

Traceback (most recent call last):
  File "psutil/tests/__main__.py", line 94, in <module>
    main()
  File "psutil/tests/__main__.py", line 91, in main
    run_suite()
  File "/Users/wrongway4you/Projects/psutil/psutil/tests/__init__.py", line 834, in run_suite
    result = unittest.TextTestRunner(verbosity=VERBOSITY).run(get_suite())
  File "/Users/wrongway4you/Projects/psutil/psutil/tests/__init__.py", line 828, in get_suite
    suite.addTest(unittest.defaultTestLoader.loadTestsFromName(tm))
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "/Users/wrongway4you/Projects/psutil/psutil/tests/test_unicode.py", line 314, in <module>
    @unittest.skipIf(not subprocess_supports_unicode(INVALID_NAME),
  File "/Users/wrongway4you/Projects/psutil/psutil/tests/test_unicode.py", line 121, in subprocess_supports_unicode
    create_exe(name)
  File "/Users/wrongway4you/Projects/psutil/psutil/tests/__init__.py", line 776, in create_exe
    shutil.copyfile(PYTHON_EXE, outpath)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 97, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 92] Illegal byte sequence: '/Users/wrongway4you/Projects/psutil/@psutil-test-5824f\xc0\x80'
make: *** [test] Error 1

@giampaolo giampaolo added critical and removed 64bit labels Feb 26, 2019
@giampaolo
Copy link
Owner

giampaolo commented Feb 26, 2019

Bumping up priority for this one. @whitlockjc Jeremy do you remember this code? Could you perhaps take a look?

psutil_proc_memory_maps(PyObject *self, PyObject *args) {

@giampaolo
Copy link
Owner

Closing this out as a duplicate of #1291.

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

3 participants