Opened 4 weeks ago

Last modified 4 weeks ago

#32049 new defect

stem/util/proc.py", line 448, in _inodes_for_sockets FileNotFoundError: [Errno 2]

Reported by: toralf Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Stem Version: Tor: 0.4.2.2-alpha
Severity: Normal Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Running https://github.com/toralf/torutils/blob/master/ps.py for about 30 minutes at a Tor relay gives

 port     # opened closed     max                ( proc:9051, 6630 conns 0.24 sec ) 
  5222    62                     62      3      1  (Jabber)
  5280     1                      1                (None)
  6660                            4             2  (IRC)
  6666                            1      1      1  (IRC)
  6667     1                      3      1      1  (IRC)
  6697     3                      3                (IRC)
Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/stem/util/proc.py", line 448, in _inodes_for_sockets
    fd_name = os.readlink(fd_path)
FileNotFoundError: [Errno 2] No such file or directory: '/proc/2284/fd/5280'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/torutils/ps.py", line 178, in <module>
    main()
  File "/opt/torutils/ps.py", line 102, in main
    connections = get_connections(resolver=resolver,process_pid=pid,process_name='tor')
  File "/usr/lib64/python3.6/site-packages/stem/util/connection.py", line 236, in get_connections
    return stem.util.proc.connections(pid = process_pid)
  File "/usr/lib64/python3.6/site-packages/stem/util/proc.py", line 374, in connections
    inodes = _inodes_for_sockets(pid) if pid else set()
  File "/usr/lib64/python3.6/site-packages/stem/util/proc.py", line 457, in _inodes_for_sockets
    raise IOError('unable to determine file descriptor destination (%s): %s' % (exc, fd_path))
OSError: unable to determine file descriptor destination ([Errno 2] No such file or directory: '/proc/2284/fd/5280'): /proc/2284/fd/5280

FWIW:

mr-fox ~ # ls /proc/2284/fd | wc
   7148    7148   34630
mr-fox ~ # for p in 9051 ; do python /usr/share/doc/stem-1.7.1/_static/example/relay_connections.py --ctrlport $p; done
 0.4.2.2-alpha   uptime: 1-16:08:14   flags: Fast, Guard, Running, Stable, V2Dir, Valid

+------------------------------+------+------+
| Type                         | IPv4 | IPv6 |
+------------------------------+------+------+
| Inbound to our ORPort        | 3661 |    4 |
| Inbound to our DirPort       |    2 |    0 |
| Inbound to our ControlPort   |    1 |    0 |
| Outbound to a relay          | 2889 |    0 |
| Outbound exit traffic        |   63 |    6 |
| Outbound uncategorized       |    8 |    0 |
+------------------------------+------+------+
| Total                        | 6624 |   10 |
+------------------------------+------+------+

+------------------------------+------+------+
| Exit Port                    | IPv4 | IPv6 |
+------------------------------+------+------+
| 5222 (Jabber)                |   54 |    5 |
| 5280                         |    1 |    0 |
| 6667 (IRC)                   |    6 |    0 |
| 6697 (IRC)                   |    2 |    1 |
+------------------------------+------+------+
| Total                        |   63 |    6 |
+------------------------------+------+------+

Child Tickets

Change History (1)

comment:1 Changed 4 weeks ago by atagar

Thanks toralf! I won't be able to get to this for a while (busy with #31823), but I'll look into adding an internal retry so shifting file descriptors won't trigger this.

Note: See TracTickets for help on using tickets.