[netsnmp 5.9] python module goes "Segmentation fault" with some (binary) OIDs ?

Diego Billi <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
I downloaded Net-nsmp 5.9 sources and installed the python module compiled for python3.

With some OID/MIBS my python program goes "Segmentation fault".

The same python code tested with python 2.7 works.

It think the problem raises when handling some binary values. 

In my test i just "walked" this MIBS:

    walk on  1.3.6.1.2.1.3.1.1.1 -> ok
    walk on  1.3.6.1.2.1.3.1.1.2 -> core dump
    walk on  1.3.6.1.2.1.3.1.1.3 -> ok

The remote target host (server1) is running a SNMPD agent.

Where am i wrong? Thank you for your time.

Diego.




########################################################################
# The content of my target's MIB with shell commands (for comparison)
########################################################################

snmpwalk -v 1 -c public server1 1.3.6.1.2.1.3.1.1.1

iso.3.6.1.2.1.3.1.1.1.2.1.1.1.0.1 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.0.14 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.0.15 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.0.27 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.0.37 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.0.53 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.0.59 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.0.60 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.2.13 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.13.252 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.14.64 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.14.104 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.15.24 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.16.22 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.17.45 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.17.57 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.17.87 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.17.189 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.17.197 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.17.220 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.17.222 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.17.223 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.18.139 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.18.189 = INTEGER: 2
iso.3.6.1.2.1.3.1.1.1.2.1.1.1.18.191 = INTEGER: 2

snmpwalk -v 1 -c public server1 1.3.6.1.2.1.3.1.1.2

iso.3.6.1.2.1.3.1.1.2.2.1.1.1.0.1 = Hex-STRING: 32 39 56 FD 26 91 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.0.14 = Hex-STRING: 72 0B 91 1E BE FC 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.0.15 = Hex-STRING: 76 C0 5C C1 97 79 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.0.27 = Hex-STRING: 00 E0 81 2E 13 33 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.0.37 = Hex-STRING: 00 C0 FF 13 42 31 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.0.53 = Hex-STRING: 84 34 97 11 C4 74 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.0.59 = Hex-STRING: 00 0C 29 5E 84 36 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.0.60 = Hex-STRING: 06 F2 CC E5 D6 23 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.2.13 = Hex-STRING: 08 2E 5F D9 8C 40 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.13.252 = Hex-STRING: 00 15 65 16 42 58 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.14.64 = Hex-STRING: 00 15 65 16 3D FA 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.14.104 = Hex-STRING: 9C B6 D0 DB 90 19 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.15.24 = Hex-STRING: 00 13 19 C8 D1 7D 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.16.22 = Hex-STRING: BA 97 11 3F 90 54 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.17.45 = Hex-STRING: 00 15 65 16 42 8C 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.17.57 = Hex-STRING: 00 15 65 16 40 92 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.17.87 = Hex-STRING: AC 2B 6E A4 A8 FD 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.17.189 = Hex-STRING: AC E2 D3 D4 1A C3 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.17.197 = Hex-STRING: 7C B0 C2 96 7F 35 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.17.220 = Hex-STRING: 00 15 65 16 44 18 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.17.222 = Hex-STRING: 00 15 65 16 44 28 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.17.223 = Hex-STRING: 00 15 65 16 44 D4 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.18.139 = Hex-STRING: 84 EF 18 2E 7B 47 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.18.189 = Hex-STRING: 00 15 65 16 44 2A 
iso.3.6.1.2.1.3.1.1.2.2.1.1.1.18.191 = Hex-STRING: 00 15 65 16 3F 18 

snmpwalk -v 1 -c public server1 1.3.6.1.2.1.3.1.1.3

iso.3.6.1.2.1.3.1.1.3.2.1.1.1.0.1 = IpAddress: 1.1.0.1
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.0.14 = IpAddress: 1.1.0.14
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.0.15 = IpAddress: 1.1.0.15
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.0.27 = IpAddress: 1.1.0.27
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.0.37 = IpAddress: 1.1.0.37
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.0.53 = IpAddress: 1.1.0.53
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.0.59 = IpAddress: 1.1.0.59
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.0.60 = IpAddress: 1.1.0.60
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.2.13 = IpAddress: 1.1.2.13
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.13.252 = IpAddress: 1.1.13.252
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.14.64 = IpAddress: 1.1.14.64
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.14.104 = IpAddress: 1.1.14.104
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.15.24 = IpAddress: 1.1.15.24
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.16.22 = IpAddress: 1.1.16.22
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.17.45 = IpAddress: 1.1.17.45
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.17.57 = IpAddress: 1.1.17.57
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.17.87 = IpAddress: 1.1.17.87
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.17.89 = IpAddress: 1.1.17.89
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.17.189 = IpAddress: 1.1.17.189
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.17.197 = IpAddress: 1.1.17.197
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.17.220 = IpAddress: 1.1.17.220
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.17.222 = IpAddress: 1.1.17.222
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.17.223 = IpAddress: 1.1.17.223
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.18.139 = IpAddress: 1.1.18.139
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.18.189 = IpAddress: 1.1.18.189
iso.3.6.1.2.1.3.1.1.3.2.1.1.1.18.191 = IpAddress: 1.1.18.191



########################################################################
# Debian 10
# Python 2.7.16
# Netsnmp 5.7.3  
#     - Installed from Debian package
########################################################################

>>> import netsnmp
>>> s = netsnmp.Session(**{'Version': 2, 'DestHost': 'server1:161', 'Community': 'public', 'Timeout': 3000000, 'Retries': 1, 'UseNumeric': 1})
>>> 
>>> var_list = netsnmp.VarList()
>>> var_list.append( netsnmp.Varbind('.1.3.6.1.2.1.3.1.1.1') )
>>> res = s.walk(var_list)
>>> for r in res:
...     print(repr(r))
... 
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'

>>> var_list = netsnmp.VarList()
>>> var_list.append( netsnmp.Varbind('.1.3.6.1.2.1.3.1.1.2') )
>>> res = s.walk(var_list)
>>> for r in res:
...     print(repr(r))
... 
'29V\xfd&\x91'
'r\x0b\x91\x1e\xbe\xfc'
'v\xc0\\\xc1\x97y'
'\x00\xe0\x81.\x133'
'\x00\xc0\xff\x13B1'
'\x844\x97\x11\xc4t'
'\x00\x0c)^\x846'
'\x06\xf2\xcc\xe5\xd6#'
'\x00\x1c.CJ '
'\x08._\xd9\x8c@'
'\x00\x15e\x16BX'
'\x9c\xb6\xd0\xdb\x90\x19'
'\xba\x97\x11?\x90T'
'\x00\x15e\x16B\x8c'
'\x00\x15e\x16@\x92'
'\xac+n\xa4\xa8\xfd'
"\x08\x00'\x9f\xba\xab"
'\xac\xe2\xd3\xd4\x1a\xc3'
'|\xb0\xc2\x96\x7f5'
'\x00\x15e\x16D\x18'
'\x84\xef\x18.{G'
'\x00\x15e\x16D*'
'\x00\x15e\x16?\x18'

>>> var_list = netsnmp.VarList()
>>> var_list.append( netsnmp.Varbind('.1.3.6.1.2.1.3.1.1.3') )
>>> res = s.walk(var_list)
>>> for r in res:
...     print(repr(r))
... 
'1.1.0.1'
'1.1.0.14'
'1.1.0.15'
'1.1.0.27'
'1.1.0.37'
'1.1.0.53'
'1.1.0.59'
'1.1.0.60'
'1.1.2.8'
'1.1.2.13'
'1.1.13.252'
'1.1.14.104'
'1.1.16.22'
'1.1.17.45'
'1.1.17.57'
'1.1.17.87'
'1.1.17.89'
'1.1.17.189'
'1.1.17.197'
'1.1.17.220'
'1.1.18.139'
'1.1.18.189'
'1.1.18.191'
>>> 

########################################################################
# Debian 10
# Python 3.7.3
# Netsnmp 5.9  
#     - Installed from sources (downloaded from main site 2020-02-01)
########################################################################

>>> import netsnmp
>>> s = netsnmp.Session(**{'Version': 2, 'DestHost': 'server1:161', 'Community': 'public', 'Timeout': 3000000, 'Retries': 1, 'UseNumeric': 1})
>>> 
>>> var_list = netsnmp.VarList()
>>> var_list.append( netsnmp.Varbind('.1.3.6.1.2.1.3.1.1.1') )
>>> res = s.walk(var_list)
>>> for r in res:
...     print(repr(r))
... 
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'
'2'

>>> 
>>> 
>>> var_list = netsnmp.VarList()
>>> var_list.append( netsnmp.Varbind('.1.3.6.1.2.1.3.1.1.2') )
>>> res = s.walk(var_list)
Segmentation fault

      ????????????????? WHY :-( ?????????????????

>>> 
>>> var_list = netsnmp.VarList()
>>> var_list.append( netsnmp.Varbind('.1.3.6.1.2.1.3.1.1.3') )
>>> res = s.walk(var_list)
>>> for r in res:
...     print(repr(r))
... 
'1.1.0.1'
'1.1.0.14'
'1.1.0.15'
'1.1.0.27'
'1.1.0.37'
'1.1.0.53'
'1.1.0.59'
'1.1.0.60'
'1.1.2.8'
'1.1.2.13'
'1.1.13.252'
'1.1.14.64'
'1.1.14.104'
'1.1.15.24'
'1.1.16.22'
'1.1.17.45'
'1.1.17.57'
'1.1.17.87'
'1.1.17.89'
'1.1.17.189'
'1.1.17.197'
'1.1.17.220'
'1.1.17.222'
'1.1.17.223'
'1.1.18.139'
'1.1.18.189'
'1.1.18.191'



_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.