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

Python interpreter crash on Windows 10 while printing processes username with another user logged in. #1258

Closed
KelSolaar opened this issue Mar 28, 2018 · 9 comments

Comments

@KelSolaar
Copy link

KelSolaar commented Mar 28, 2018

Hi,

We are experiencing hard Python interpreter crash on Windows 10 and psutil 5.4.3 when printing processes username with another user logged. Basically I'm logged into the workstation and another user is also logged in on his account. The crash happens when trying to list the processes username the second time.

Here is the reproducible code:

import psutil


def list_processes_username():
    for pid in psutil.pids():
        if not psutil.pid_exists(pid):
            continue

        try:
            print(psutil.Process(pid).username())
        except psutil.AccessDenied:
            pass


print(list_processes_username())
print(list_processes_username())

Crash Dialog:

image

Current Windows version:

image

@KelSolaar
Copy link
Author

By printing the PIDs and checking in the Task Manager I was able to confirm that it is when trying to access a process from the other user.

@giampaolo
Copy link
Owner

Shit...
What Python and Windows version is this?

@KelSolaar
Copy link
Author

Python 2.7, Windows version is in the last screenshot of OP.

@giampaolo
Copy link
Owner

Python 2.7 32 or 64 bit?

@KelSolaar
Copy link
Author

KelSolaar commented Apr 12, 2018

64bit! Sorry for not being specific. I need to double-check at work but very likely this one: https://www.python.org/ftp/python/2.7.14/python-2.7.14.amd64.msi

@giampaolo
Copy link
Owner

No worries. As expected, I cannot reproduce it. I tried with this with no luck:

import psutil

while 1:
    for p in psutil.process_iter():
        try:
            print(p.username())
        except psutil.AccessDenied:
            pass

Can you identify the PID causing the crash, run this script and paste the output?

from pprint import pprint as pp
import psutil
attrs = set(['num_ctx_switches', 'pid', 'memory_full_info', 'connections', 'cmdline', 'create_time', 'ionice', 'memory_maps', 'cpu_percent', 'ppid', 'cwd', 'nice', 'status', 'cpu_times', 'io_counters', 'memory_info', 'threads', 'open_files', 'num_threads', 'exe', 'name', 'cpu_affinity', 'memory_percent', 'environ'])
PID = 1283
pp(psutil.Process(PID).as_dict(attrs=attrs))

@KelSolaar
Copy link
Author

Yeah, I'll try that at work, we might be able to provide a stack trace. I'll keep you posted.

nikhilm added a commit to nikhilm/psutil that referenced this issue May 15, 2018
@giampaolo
Copy link
Owner

New release is out. Can you please check whether this got fixed?

@KelSolaar
Copy link
Author

KelSolaar commented Aug 8, 2018

Hi @giampaolo,

Sorry for the late reply, I was swamped at worked and this fell down the priority stack. I have some good news though, 5.4.6 fixed the issue for me, I could confirm it multiple times by switching the package versions, 5.4.5 crashes, 5.4.6 does not! Thanks a lot.

Cheers,

Thomas

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

2 participants