nikademus79 / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

Process.get_connections() is broken on big-endian architectures #201

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,
followuing up issue 200, I gave a look at what's happening on sparc about:

FAIL: test_get_connections (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/test_psutil.py", line 147, in inner
    return fun(self, *args, **kwargs)
  File "test/test_psutil.py", line 974, in test_get_connections
    self.assertEqual(ip, '127.0.0.1')
AssertionError: '1.0.0.127' != '127.0.0.1'

The problem (that I think it's related to the endianess of the architecture) is 
that _decode_address() expect 127.0.0.1 in a line like this

   2: 0100007F:1DD2 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 6797 1 ffff880115776040 300 0 0 2 -1                      

while on sparc you'd get something like:

   2: 7F000001:A13F 00000000:0000 0A 00000000:00000000 00:00000000 00000000  2940        0 41019895 1 fffff8103c59be80 300 0 0 2 -1                  

so the second field (the local address) is in reverse.

The different ordering might come up even on other part of the code.

If you need any help in debugging further, don't hesitate to contact me.

Cheers,
Sandro

Original issue reported on code.google.com by matrixhasu on 28 Aug 2011 at 2:57

GoogleCodeExporter commented 8 years ago
I can see an error like this even on: mips (but not on mipsel, which is little 
endian, so it's definitely alignment-related), powerpc and s390 .

Original comment by matrixhasu on 28 Aug 2011 at 10:55

GoogleCodeExporter commented 8 years ago
Can you please check whether this patch works (note: I still haven't took care 
of IPv6)?

Original comment by g.rodola on 29 Aug 2011 at 10:49

Attachments:

GoogleCodeExporter commented 8 years ago
Yep, it works fine (I tested both on a little and big endian box)

Original comment by matrixhasu on 29 Aug 2011 at 5:54

GoogleCodeExporter commented 8 years ago
This should now be fixed in r1113 and r1114.
I've also added a brand new IPv6-related test so please re-run tests to make 
sure everything is fine.

Original comment by g.rodola on 29 Aug 2011 at 8:06

GoogleCodeExporter commented 8 years ago
It works fine either on sparc and on amd64 (so 2 different endian machines). 
Ah, since you're giving me credit (thanks about that!) you might want to refer 
to my real name "Sandro Tosi" (for the email you can use sandro.tosi@gmail.com 
or morph@debian.org).

Original comment by matrixhasu on 29 Aug 2011 at 8:27

GoogleCodeExporter commented 8 years ago
Oh yeah, we met at Euro Python in Florence this very year. =)
Fixed in r1115.

Original comment by g.rodola on 29 Aug 2011 at 8:31

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 21 Oct 2011 at 11:44

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 21 Oct 2011 at 11:45

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 29 Oct 2011 at 3:44

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Updated csets after the SVN -> Mercurial migration:
r1113 == revision e00994c657c0
r1115 == revision 3671d370e764

Original comment by g.rodola on 2 Mar 2013 at 12:03