-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
mac m1 RuntimeError: proc_pidinfo(PROC_PIDLISTFDS) 2/2 syscall failed #2116
Comments
I could reproduce this on my virtualized osx and it turns out the crash is due |
I'm getting something very similar on my mac m1:
I'm storing the exception in a file because the parent process ( I'm trying to figure out a minimal example. |
Python script to listen to a given port: #!/usr/bin/env python
import socket
import sys
HOST = "0.0.0.0"
PORT = int(sys.argv[1])
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
while True:
data = conn.recv(1024)
if data.decode() == "bye":
break
conn.sendall(data)
conn, addr = s.accept() Script that will cause the exception given above if import os
import traceback
from subprocess import Popen
import psutil
from daemon import DaemonContext
cwd = os.getcwd()
port = 51371
nc_cmd = ["/usr/bin/nc", "-l", str(port)]
echo_cmd = ["/Users/horta/code/h3daemon-bug/echo.py", str(port)]
if __name__ == "__main__":
with DaemonContext():
master = Popen(nc_cmd)
# master = Popen(echo_cmd)
x = master.pid
try:
for x in psutil.Process(master.pid).connections(kind="tcp"):
pass
except Exception:
traceback.print_exc(file=open(f"{cwd}/exception.txt", "w")) The bug does not happen without DaemonContext(), python-daemon.
|
I'm still getting the same error on MacOS Sequoia, mac mini M1, psutil 6.1.0:
|
This comment was marked as off-topic.
This comment was marked as off-topic.
The solution might be here: https://github.com/lsof-org/lsof/blob/bbf320ce586a848f880bca7b758d50ae4c712624/lib/dialects/darwin/dproc.c#L480 It returns with no error in case |
That would explain why I don't get that error when I provide stdout or stderr to the daemon process. |
My current workaround: from psutil import Process
__all__ = ["tcp_connections"]
def tcp_connections(x: Process):
# psutil bug: https://github.com/giampaolo/psutil/issues/2116
with open("/dev/null", "wb"):
connections = x.net_connections(kind="tcp")
return connections |
Sorry, the above workaround didnt work when I used breakpoints. Please, advise me on how to debug it for you... |
Summary
Description
hello all:
my code:
use error:
How can I solve this problem, thanks
The text was updated successfully, but these errors were encountered: