snmp++v3 crashes after version upgrade.

By | August 26, 2024

SNMP++v3.x is free open source c++ API library which may be used in different operating systems such as Linux, FreeBSD, Mac OS X, Solaris and Windows. Initially it was developed by Hewlett-Packard, but currently maintained by AGENTPP. I started to use it beginning from version snmp++-3.2.17 and time by time upgrading to newer one. Usually upgrade did not create any problem. But after recent upgrade to version snmp++v3.5.2 my application began crashing in snmp++ code. The crash stack was:


Snmp_pp::v3MP::EngineIdTable::get_entry (this=this@entry=0x0, engine_id=…, host=…, port=port@entry=161) at mp_v3.cpp:208
#0 Snmp_pp::v3MP::EngineIdTable::get_entry (this=this@entry=0x0, engine_id=…, host=…, port=port@entry=161) at mp_v3.cpp:208
#1 0x00007ffff6365592 in Snmp_pp::v3MP::EngineIdTable::get_entry (this=0x0, engine_id=…, hostport=…) at mp_v3.cpp:201
#2 0x00007ffff638a6b1 in get_from_engine_id_table (hostport=…, engine_id=…, this=) at /home/jenkins/agent/workspace/RAL_BUILD_Release_release_2024.5/WORKSPACE/rhel7_64/agent-tar/BUILD/Development/n-central/support/snmp++-3.5.1/include/snmp_pp/mp_v3.h:212
#3 Snmp_pp::Snmp::snmp_engine (this=0x7fffdc014cf0, pdu=…, non_reps=0, max_reps=10, target=…, cb=cb@entry=0x0, cbd=cbd@entry=0x0, fd=fd@entry=-1, reports_received=reports_received@entry=0, snmp_message=snmp_message@entry=0x0) at uxsnmp.cpp:1780
#4 0x00007ffff638c015 in Snmp_pp::Snmp::get_bulk (this=, pdu=…, target=…, non_repeaters=, max_reps=) at uxsnmp.cpp:1105

The code from mp_v3.cpp where crashed happened was:


int v3MP::EngineIdTable::get_entry(OctetStr &engine_id,
        const OctetStr &host, int port) const
{
  if (!table)   // <= line 208
    return SNMPv3_MP_NOT_INITIALIZED;

  BEGIN_REENTRANT_CODE_BLOCK_CONST;

After analyzing several example I found that new version is required addition initialization step of Snmp class object. The step is:


snmp.set_mpv3(v3_MP); // must be set since 3.4.0

Leave a Reply

Your email address will not be published. Required fields are marked *