Skip to content

Commit

Permalink
Use vmmap for reading memory maps on macOS
Browse files Browse the repository at this point in the history
Call to .memory_maps() fails on Azure pipelines with:

    Traceback (most recent call last):
        ...
        return cext.proc_memory_maps(self.pid)
    OSError: [Errno 22] Invalid argument

Also, support for memory_maps() has been removed for macOS starting
psutil-v5.6.x xref: giampaolo/psutil#1291
  • Loading branch information
nehaljwani committed Mar 24, 2019
1 parent 55deb2b commit 0842598
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions recipe/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
import psutil
import platform
import subprocess

libname = re.escape(os.environ['CONDA_PREFIX']) + '.*(libgmp.*.(dylib|so))'

Expand All @@ -14,5 +15,10 @@
from Cryptodome.Math import _IntegerGMP as IntegerGMP

# Make sure that gmp is indeed loaded in memory
p = psutil.Process(os.getpid())
assert any(bool(re.match(libname, x.path)) for x in p.memory_maps())
if psutil.MACOS:
vmmap_out = subprocess.check_output(['vmmap', '-w', str(os.getpid())])
assert re.search(re.compile(libname), vmmap_out.decode('utf-8'))

if psutil.LINUX:
p = psutil.Process(os.getpid())
assert any(bool(re.match(libname, x.path)) for x in p.memory_maps())

0 comments on commit 0842598

Please sign in to comment.