Exception in SNMP++

Greetings,

I am getting an exception when using SNMP++ version 3.5.0. I didn’t find this issue reported recently in this community. Any idea if this was seen before or addressed? Thanks

Exception Information: The Thread tried to read from or write to a virtual address for which it doesn’t have the appropriate access.
Exception code : 0xC0000005

Backtrace.
CSNMPMessageQueue::GetNextTimeoutEntry() : msgqueue.cpp
CSNMPMessageQueue::GetNextTimeout(msec &sendTime) : msgqueue.cpp
CEventList::GetNextTimeout(msec &sendTime) eventlist.cpp
EventListHolder::SNMPProcessEvents(const int max_block_milliseconds)
EventListHolder::SNMPBlockForResponse(const unsigned long req_id, Pdu &pdu)
Snmp::snmp_engine( Pdu &pdu, // pdu to use
long int non_reps, // # of non repititions
long int max_reps, // # of max repititions
SnmpTarget &target, // from this target
const snmp_callback cb,// callback for async calls
const void *cbd, // callback data
SnmpSocket fd,
int reports_received,
CSNMPMessage *snmp_message)
Snmp::get(Pdu &pdu, SnmpTarget &target)

Hi,

are you using snmp++ within a .net environment?
The error looks like the Snmp object was destroyed while the call to Snmp::get() was still active and waiting for the response. So my question is: What are the other threads doing with the Snmp object during this time and is there a chance that it is destroyed?

Kind regards,
Jochen

Hi Jochen,

Thanks for you comments.

We are using SNMP++ in C++ environment (Windows). From the dump I don’t see any thread in shutdown state. But there are couple of threads for which I am not able to get the backtrace. Here are backtrace of the threads:

    Main tread:
[External Code]	
Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code).

    Thread generated excpetion / dump:

SNMP++.dll!Snmp_pp::CSNMPMessageQueue::GetNextTimeoutEntry() Line 495 C++
SNMP++.dll!Snmp_pp::CSNMPMessageQueue::GetNextTimeout(Snmp_pp::msec & sendTime) Line 510 C++
SNMP++.dll!Snmp_pp::CEventList::GetNextTimeout(Snmp_pp::msec & sendTime) Line 122 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessEvents(const int max_block_milliseconds) Line 267 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPBlockForResponse(const unsigned long req_id, Snmp_pp::Pdu & pdu) Line 78 C++
SNMP++.dll!Snmp_pp::Snmp::snmp_engine(Snmp_pp::Pdu & pdu, long non_reps, long max_reps, Snmp_pp::SnmpTarget & target, void(*)(int, Snmp_pp::Snmp *, Snmp_pp::Pdu &, Snmp_pp::SnmpTarget &, void *) cb, const void * cbd, unsigned __int64 fd, int reports_received, Snmp_pp::CSNMPMessage * snmp_message) Line 1918 C++
SNMP++.dll!Snmp_pp::Snmp::get(Snmp_pp::Pdu & pdu, Snmp_pp::SnmpTarget & target) Line 1055 C++
[External Code]

[External Code]	

SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessPendingEvents() Line 226 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessEvents(const int max_block_milliseconds) Line 289 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPBlockForResponse(const unsigned long req_id, Snmp_pp::Pdu & pdu) Line 78 C++
SNMP++.dll!Snmp_pp::Snmp::snmp_engine(Snmp_pp::Pdu & pdu, long non_reps, long max_reps, Snmp_pp::SnmpTarget & target, void(*)(int, Snmp_pp::Snmp *, Snmp_pp::Pdu &, Snmp_pp::SnmpTarget &, void *) cb, const void * cbd, unsigned __int64 fd, int reports_received, Snmp_pp::CSNMPMessage * snmp_message) Line 1918 C++
SNMP++.dll!Snmp_pp::Snmp::get(Snmp_pp::Pdu & pdu, Snmp_pp::SnmpTarget & target) Line 1055 C++
[External Code]

SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessPendingEvents() Line 226 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessEvents(const int max_block_milliseconds) Line 289 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPBlockForResponse(const unsigned long req_id, Snmp_pp::Pdu & pdu) Line 78 C++
SNMP++.dll!Snmp_pp::Snmp::snmp_engine(Snmp_pp::Pdu & pdu, long non_reps, long max_reps, Snmp_pp::SnmpTarget & target, void(*)(int, Snmp_pp::Snmp *, Snmp_pp::Pdu &, Snmp_pp::SnmpTarget &, void *) cb, const void * cbd, unsigned __int64 fd, int reports_received, Snmp_pp::CSNMPMessage * snmp_message) Line 1918 C++
SNMP++.dll!Snmp_pp::Snmp::get(Snmp_pp::Pdu & pdu, Snmp_pp::SnmpTarget & target) Line 1055 C++
[External Code]

[External Code]	

SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessPendingEvents() Line 226 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessEvents(const int max_block_milliseconds) Line 289 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPBlockForResponse(const unsigned long req_id, Snmp_pp::Pdu & pdu) Line 78 C++
SNMP++.dll!Snmp_pp::Snmp::snmp_engine(Snmp_pp::Pdu & pdu, long non_reps, long max_reps, Snmp_pp::SnmpTarget & target, void(*)(int, Snmp_pp::Snmp *, Snmp_pp::Pdu &, Snmp_pp::SnmpTarget &, void *) cb, const void * cbd, unsigned __int64 fd, int reports_received, Snmp_pp::CSNMPMessage * snmp_message) Line 1918 C++
SNMP++.dll!Snmp_pp::Snmp::get(Snmp_pp::Pdu & pdu, Snmp_pp::SnmpTarget & target) Line 1055 C++
[External Code]

[External Code]	

SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessPendingEvents() Line 226 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessEvents(const int max_block_milliseconds) Line 289 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPBlockForResponse(const unsigned long req_id, Snmp_pp::Pdu & pdu) Line 78 C++
SNMP++.dll!Snmp_pp::Snmp::snmp_engine(Snmp_pp::Pdu & pdu, long non_reps, long max_reps, Snmp_pp::SnmpTarget & target, void(*)(int, Snmp_pp::Snmp *, Snmp_pp::Pdu &, Snmp_pp::SnmpTarget &, void *) cb, const void * cbd, unsigned __int64 fd, int reports_received, Snmp_pp::CSNMPMessage * snmp_message) Line 1918 C++
SNMP++.dll!Snmp_pp::Snmp::get(Snmp_pp::Pdu & pdu, Snmp_pp::SnmpTarget & target) Line 1055 C++
[External Code]

[External Code]	

SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessPendingEvents() Line 226 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessEvents(const int max_block_milliseconds) Line 289 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPBlockForResponse(const unsigned long req_id, Snmp_pp::Pdu & pdu) Line 78 C++
SNMP++.dll!Snmp_pp::Snmp::snmp_engine(Snmp_pp::Pdu & pdu, long non_reps, long max_reps, Snmp_pp::SnmpTarget & target, void(*)(int, Snmp_pp::Snmp *, Snmp_pp::Pdu &, Snmp_pp::SnmpTarget &, void *) cb, const void * cbd, unsigned __int64 fd, int reports_received, Snmp_pp::CSNMPMessage * snmp_message) Line 1918 C++
SNMP++.dll!Snmp_pp::Snmp::get(Snmp_pp::Pdu & pdu, Snmp_pp::SnmpTarget & target) Line 1055 C++
[External Code]

[External Code]	

SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessPendingEvents() Line 226 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessEvents(const int max_block_milliseconds) Line 289 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPBlockForResponse(const unsigned long req_id, Snmp_pp::Pdu & pdu) Line 78 C++
SNMP++.dll!Snmp_pp::Snmp::snmp_engine(Snmp_pp::Pdu & pdu, long non_reps, long max_reps, Snmp_pp::SnmpTarget & target, void(*)(int, Snmp_pp::Snmp *, Snmp_pp::Pdu &, Snmp_pp::SnmpTarget &, void *) cb, const void * cbd, unsigned __int64 fd, int reports_received, Snmp_pp::CSNMPMessage * snmp_message) Line 1918 C++
SNMP++.dll!Snmp_pp::Snmp::get(Snmp_pp::Pdu & pdu, Snmp_pp::SnmpTarget & target) Line 1055 C++
[External Code]

[External Code]	

SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessPendingEvents() Line 226 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessEvents(const int max_block_milliseconds) Line 289 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPBlockForResponse(const unsigned long req_id, Snmp_pp::Pdu & pdu) Line 78 C++
SNMP++.dll!Snmp_pp::Snmp::snmp_engine(Snmp_pp::Pdu & pdu, long non_reps, long max_reps, Snmp_pp::SnmpTarget & target, void(*)(int, Snmp_pp::Snmp *, Snmp_pp::Pdu &, Snmp_pp::SnmpTarget &, void *) cb, const void * cbd, unsigned __int64 fd, int reports_received, Snmp_pp::CSNMPMessage * snmp_message) Line 1918 C++
SNMP++.dll!Snmp_pp::Snmp::get(Snmp_pp::Pdu & pdu, Snmp_pp::SnmpTarget & target) Line 1055 C++
[External Code]

[External Code]	

SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessPendingEvents() Line 226 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessEvents(const int max_block_milliseconds) Line 289 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPBlockForResponse(const unsigned long req_id, Snmp_pp::Pdu & pdu) Line 78 C++
SNMP++.dll!Snmp_pp::Snmp::snmp_engine(Snmp_pp::Pdu & pdu, long non_reps, long max_reps, Snmp_pp::SnmpTarget & target, void(*)(int, Snmp_pp::Snmp *, Snmp_pp::Pdu &, Snmp_pp::SnmpTarget &, void *) cb, const void * cbd, unsigned __int64 fd, int reports_received, Snmp_pp::CSNMPMessage * snmp_message) Line 1918 C++
SNMP++.dll!Snmp_pp::Snmp::get(Snmp_pp::Pdu & pdu, Snmp_pp::SnmpTarget & target) Line 1055 C++
[External Code]

[External Code]	

[Inline Frame] SNMP++.dll!Snmp_pp::SnmpSynchronize::{ctor}(Snmp_pp::SnmpSynchronized &) Line 71 C++
SNMP++.dll!Snmp_pp::CEventList::GetNextTimeout(Snmp_pp::msec & sendTime) Line 122 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessEvents(const int max_block_milliseconds) Line 267 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPBlockForResponse(const unsigned long req_id, Snmp_pp::Pdu & pdu) Line 78 C++
SNMP++.dll!Snmp_pp::Snmp::snmp_engine(Snmp_pp::Pdu & pdu, long non_reps, long max_reps, Snmp_pp::SnmpTarget & target, void(*)(int, Snmp_pp::Snmp *, Snmp_pp::Pdu &, Snmp_pp::SnmpTarget &, void *) cb, const void * cbd, unsigned __int64 fd, int reports_received, Snmp_pp::CSNMPMessage * snmp_message) Line 1918 C++
SNMP++.dll!Snmp_pp::Snmp::get(Snmp_pp::Pdu & pdu, Snmp_pp::SnmpTarget & target) Line 1055 C++
[External Code]

[External Code]	

[Inline Frame] SNMP++.dll!Snmp_pp::SnmpSynchronize::{ctor}(Snmp_pp::SnmpSynchronized &) Line 71 C++
SNMP++.dll!Snmp_pp::CEventList::GetNextTimeout(Snmp_pp::msec & sendTime) Line 122 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPProcessEvents(const int max_block_milliseconds) Line 267 C++
SNMP++.dll!Snmp_pp::EventListHolder::SNMPBlockForResponse(const unsigned long req_id, Snmp_pp::Pdu & pdu) Line 78 C++
SNMP++.dll!Snmp_pp::Snmp::snmp_engine(Snmp_pp::Pdu & pdu, long non_reps, long max_reps, Snmp_pp::SnmpTarget & target, void(*)(int, Snmp_pp::Snmp *, Snmp_pp::Pdu &, Snmp_pp::SnmpTarget &, void *) cb, const void * cbd, unsigned __int64 fd, int reports_received, Snmp_pp::CSNMPMessage * snmp_message) Line 1918 C++
SNMP++.dll!Snmp_pp::Snmp::get(Snmp_pp::Pdu & pdu, Snmp_pp::SnmpTarget & target) Line 1055 C++
[External Code]

Hi,

are you using a singe Snmp object for all of the active get requests? Or do you use multiple Snmp objects that are created and destroyed during application execution?
Can you print the values of the variables m_msgCount, m_head, msgEltPtr, msg in the crashing function?

Did you successfully use an older version of snmp++? Can you easily reproduce this crash and how does the workload look like? (e.g. sending about 500 synchronous requests per minute to about 100 agents).

Kind regards,
Jochen

Hi Jochen,

I use Single SNMP request for all Get requests. I have used older version of SNMP++ and haven’t seen this issue. I am not able to reproduce this issue so far. Also this has happened only once so far.

I will try to reproduce the issue locally with instrumentation suggested so that it doesn’t flood the logs.

Thanks
Gaurav