I’ve got a multithreaded application which talks to multiple agents (switches, routers and other devices). Each device can be configured differently so when using SNMP v3 I can’t have a single USM as the same “user” might exist on different devices with entirely different authPriv values.
To avoid complexity, I am creating a unique v3MP per SNMP session. This works well and avoids any security clashes. However, we get random crashes in calls like EventListHolder::SNMPBlockForResponse() and when we debug we can see that this = 0x0 !?
My “fix” has been remove v3MP::I completely and initialise the v3MP in the Snmp constructor to nullptr and then call set_mpv3() explicitly … and now things no longer crash
The use of v3MP::I in a multithreaded programs seems flawed, especially as it is set to 0 when any v3MP() object is destroyed? If a program needs such a global then surely its pretty simple to create one and set it using set_mpv3() as needed? Or better yet, add a new constructor which allows the v3MP to passed into Snmp()
I will confess I don’t really understand why removing the v3MP::I stops my crashes as each Snmp object should still have its own reference. C++ isn’t my primary programming experience so I might well have missed something!
I am using SNMP++ 3.6.1 and I’ve seen crashes on Linux and Windows