[AGENT++] Crash in multi-threaded SNMP++ use (usm_v3.cpp:1262)

Jochen Katz katz at agentpp.com
Mon Mar 13 21:15:48 CET 2006


Hi John,

> 2) In each individual thread (the application creates about 80 threads
> dedicated to polling individual SNMP enabled devices) I create a new Snmp
> object and intialize it with the right settings, as part of this if the
> device to be polled is SNMP v3 then I do:
> USM *usm = v3_MP->get_usm();
> usm->add_usm_user(device.snmp_configuration.version3.snmp_username,
>                 authProtocol, privProtocol,
>                 device.snmp_configuration.version3.snmp_auth_password,
>                 device.snmp_configuration.version3.snmp_priv_password);

> It's my understanding this should be thread safe

yes it should be thread safe, but it is not. As it isn't a simple
lock/unlock issue you have to use the following temporary workaround
until I can provide a fixed version.
Add Snmp::v3Lock.lock(); and Snmp::v3Lock.unlock(); around the call to
add_usm_user().

> res->engineID           = user_table_entry->usmUserEngineID;
> 
> The problem seems to be that user_table_entry is NULL.  Right above the line
> that crashses there is a check that res is not null, but no check on
> user_table_entry.

The check for user_table_entry is left out, because the code above
should make sure that it is set. Is it possible that two of your threads
try to add the same user at the same time? Then the second thread could
delete the newly added entry of the first thread.

Just an additional hint: Adding user names takes some time (ok, not that
much on current hardware), so it would be better to add each user once
and only change it if needed.

Regards,
  Jochen




More information about the AGENTPP mailing list