python3-netsnmp
python3-netsnmp copied to clipboard
Alpine linux container process that make netsnmp get calls core dumped
We are planning to migrate our app to Alpine linux 3.18.3 and doing some testing in lowers recently. Found the python3 process core dumps when making snmp get and getbulk calls.
OS
/app # cat /etc/os-release NAME="Alpine Linux" ID=alpine VERSION_ID=3.18.3 PRETTY_NAME="Alpine Linux v3.18" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues" /app #
Installed Alpine Linux Packages
/app # apk list -i | grep installed | grep snmp net-snmp-5.9.3-r3 x86_64 {net-snmp} (Net-SNMP) [installed] net-snmp-agent-libs-5.9.3-r3 x86_64 {net-snmp} (Net-SNMP) [installed] net-snmp-dev-5.9.3-r3 x86_64 {net-snmp} (Net-SNMP) [installed] net-snmp-libs-5.9.3-r3 x86_64 {net-snmp} (Net-SNMP) [installed] net-snmp-tools-5.9.3-r3 x86_64 {net-snmp} (Net-SNMP) [installed]
OS snmpget call
/app # snmpget -v2c -c xxxxxx -On xx.xx.xxx.xxx .1.3.6.1.2.1.10.127.1.1.5.0 .1.3.6.1.2.1.10.127.1.1.5.0 = INTEGER: 5 /app #
Python3 Session
/app # python3 Python 3.11.5 (main, Aug 26 2023, 11:59:23) [GCC 12.2.1 20220924] on linux Type "help", "copyright", "credits" or "license" for more information.
import netsnmp snmpsession = netsnmp.Session(Version=2, DestHost='xx.xx.xxx.xxx', Community='xxxxxxxxx', UseNumeric=1, Timeout=2000000, Retries=1) snmpsession.UseSprintValue = 1 snmpsession.UseEnums = 1 var_list = netsnmp.VarList() var_list.append(netsnmp.Varbind('.1.3.6.1.2.1.10.127.1.1.5.0')) snmpsession.get(var_list) Segmentation fault (core dumped) /app #
When I tried to debug using gdb, I see it runs into issue when running "py_netsnmp_attr_set_string" function. Attached are stack trace and full stack trace log files for your reference.
Adding our existing QA environment for your reference where app works fine on Alpine Linux 3.14.x
Working OS
/app # cat /etc/os-release NAME="Alpine Linux" ID=alpine VERSION_ID=3.14.8 PRETTY_NAME="Alpine Linux v3.14" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://bugs.alpinelinux.org/" /app # /app # apk list -i | grep installed | grep snmp net-snmp-dev-5.9.3-r0 x86_64 {net-snmp} (Net-SNMP) [installed] net-snmp-libs-5.9.3-r0 x86_64 {net-snmp} (Net-SNMP) [installed] net-snmp-agent-libs-5.9.3-r0 x86_64 {net-snmp} (Net-SNMP) [installed] net-snmp-tools-5.9.3-r0 x86_64 {net-snmp} (Net-SNMP) [installed] net-snmp-5.9.3-r0 x86_64 {net-snmp} (Net-SNMP) [installed] /app # snmpget -v2c -c xxxxxxxxx xx.xx.xxx.xxx .1.3.6.1.2.1.10.127.1.1.5.0 SNMPv2-SMI::transmission.127.1.1.5.0 = INTEGER: 5 /app # snmpget -v2c -c xxxxxxxxx -On xx.xx.xxx.xxx .1.3.6.1.2.1.10.127.1.1.5.0 .1.3.6.1.2.1.10.127.1.1.5.0 = INTEGER: 5 /app #
Python3 Session with no issue
/app # python3 Python 3.9.16 (main, Dec 10 2022, 13:47:19) [GCC 10.3.1 20210424] on linux Type "help", "copyright", "credits" or "license" for more information.
import netsnmp snmpsession = netsnmp.Session(Version=2, DestHost='xx.xx.xxx.xxx', Community='xxxxxxxx', UseNumeric=1, Timeout=2000000, Retries=1) snmpsession.UseSprintValue = 1 snmpsession.UseEnums = 1 var_list = netsnmp.VarList() var_list.append(netsnmp.Varbind('.1.3.6.1.2.1.10.127.1.1.5.0')) snmpsession.get(var_list) (b'5',)
Please let me know if you need any additional details.