Menu

#1222 fix for recursive pthread mutexes

closed
None
5
2012-11-09
2012-07-25
No

Motivation:
I'm using the net-snmp library as part of a bigger project. The software is multi-threaded, so we use "--enable-reentrant" when configuring net-snmp. Unfortunately, this leads to lockups in some situations: the library "hangs" when locking a pthread mutex (on Linux). After some debugging I found out that the library tries to lock the same mutex twice.

The pthread mutexes are initialized using the "default mutex attributes" (that's what the manpage of pthread_mutex_init says), and trying to lock those more than once results in undefined behaviour (according to the manpage for pthread_mutex_lock).

I created a patch against net-snmp-5.7.1 to fix the mutex initialization, so that they have the type PTHREAD_MUTEX_RECURSIVE. I shortly tested it under Linux (Redhat and Debian) as well as Solaris. Feedback is welcome :)

Discussion

  • Anonymous

    Anonymous - 2012-07-25
     
  • Wes Hardaker

    Wes Hardaker - 2012-07-30

    Thanks for the patch! It has been applied to the 5.4.x and above code branches and the main development tree, and will appear in future releases of the Net-SNMP package.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.