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

[AIX] RuntimeError: structure size mismatch when process_iter is used #1575

Closed
bartekmp opened this issue Aug 30, 2019 · 8 comments
Closed

Comments

@bartekmp
Copy link

AIX

  • { AIX 7.2 }
  • { psutil 5.6.2 }

Bug description
From time to time we encounter weird issue when using psutil on our AIX setup. It is yet unclear how to reproduce it. Notice the AttributeError being thrown in _common.py at first.

Traceback (most recent call last):
  File "/home/user/tests/venv/lib/python3.6/site-packages/psutil/_common.py", line 342, in wrapper
    ret = self._cache[fun]
AttributeError: _cache

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/tests/test_common/platform_utils.py", line 46, in 
    running_processes = [process.info for process in psutil.process_iter(attrs=["pid", "name"])]
  File "/home/user/tests/venv/lib/python3.6/site-packages/psutil/__init__.py", line 1570, in process_iter
    if proc.is_running():
  File "/home/user/tests/venv/lib/python3.6/site-packages/psutil/__init__.py", line 694, in is_running
    return self == Process(self.pid)
  File "/home/user/tests/venv/lib/python3.6/site-packages/psutil/__init__.py", line 446, in __init__
    self._init(pid)
  File "/home/user/tests/venv/lib/python3.6/site-packages/psutil/__init__.py", line 473, in _init
    self.create_time()
  File "/home/user/tests/venv/lib/python3.6/site-packages/psutil/__init__.py", line 823, in create_time
    self._create_time = self._proc.create_time()
  File "/home/user/tests/venv/lib/python3.6/site-packages/psutil/_psaix.py", line 329, in wrapper
    return fun(self, *args, **kwargs)
  File "/home/user/tests/venv/lib/python3.6/site-packages/psutil/_psaix.py", line 422, in create_time
    return self._proc_basic_info()[proc_info_map['create_time']]
  File "/home/user/tests/venv/lib/python3.6/site-packages/psutil/_psaix.py", line 329, in wrapper
    return fun(self, *args, **kwargs)
  File "/home/user/tests/venv/lib/python3.6/site-packages/psutil/_common.py", line 345, in wrapper
    return fun(self)
  File "/home/user/tests/venv/lib/python3.6/site-packages/psutil/_psaix.py", line 378, in _proc_basic_info
    return cext.proc_basic_info(self.pid, self._procfs_path)
RuntimeError: structure size mismatch

For now I use this snippet to reproduce the problem, cause I've got no idea what is a precondition to make it happen again:

for i in range(1000000000):
    try:
        running_processes = [process.info for process in psutil.process_iter(attrs=["pid", "name"])]
    except RuntimeError as re:
      print(f"Error caught: {re}")
      break 
@wiggin15
Copy link
Collaborator

I am unable to reproduce this on my setup. Can you please share a few more details?

  • Exact AIX version (including TL and SP - oslevel -s)
  • Python version (python -V)
  • Python build architecture (python -c "import platform; print(platform.architecture())")

@bartekmp
Copy link
Author

Here it is.

AIX version:

$ oslevel -s
7200-03-02-1845

Python version:

$ python -V
Python 3.6.6

Python build:

$ python -c "import platform; print(platform.architecture())"
('64bit', 'COFF')

@wiggin15
Copy link
Collaborator

wiggin15 commented Oct 2, 2019

I'm afraid I still can't reproduce this, with the same OS level and build architecture of Python.
One way to start debugging this would be to edit the code, so the message will be more helpful, and then rebuild psutil...
The relevant code is in _psutil_aix.c, line 83:

-        PyErr_SetString(PyExc_RuntimeError, "structure size mismatch");
+        PyErr_SetString(PyExc_RuntimeError, "structure size mismatch %s %zu %zu", path, size, nbytes);

This way we can find out which file is casing trouble and how.

@bartekmp
Copy link
Author

bartekmp commented Oct 3, 2019

Sure, I get it, it's very difficult to reproduce it, even in our setup. I don't know if my team will be eager to recompile psutil with your change, so I guess you can put this ticket "on hold" for now. If I collect some more interesting data, I will get back here and let you know.

@pauloamed
Copy link

Any news on this issue?

@no-response
Copy link

no-response bot commented Jan 2, 2021

This issue has been automatically closed because there has been no response for more information from the original author. Please reach out if you have or find the answers requested so that this can be investigated further.

@no-response no-response bot closed this as completed Jan 2, 2021
@albertvaka
Copy link

@bartekmp did you manage to fix this? We also saw it happen.

@KyleTheScientist
Copy link

I am also seeing this issue on AIX

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

6 participants