[Home]

Summary:ASTERISK-24905: wrong mutex macros in include/asterisk/lock.h
Reporter:Manuel Meitinger (meitinger)Labels:
Date Opened:2015-03-24 12:42:28Date Closed:2020-12-29 08:04:11.000-0600
Priority:MajorRegression?
Status:Closed/CompleteComponents:Core/BuildSystem
Versions:13.2.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Cygwin, OtherAttachments:
Description:During configure * checks for {{PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP}} and {{PTHREAD_MUTEX_RECURSIVE_NP}}. If not both are defined (e.g. on Cygwin), * sets
{{PTHREAD_MUTEX_INIT_VALUE}} to {{PTHREAD_MUTEX_INITIALIZER}} which, however, is not recursive and leads to deadlocks.

The easy solution is to change {{PTHREAD_MUTEX_INITIALIZER}} to {{PTHREAD_RECURSIVE_MUTEX_INITIALIZER}}.
A better solution is to handle the initializer and the flag separately:
{code}
#if defined(HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
#define PTHREAD_MUTEX_INIT_VALUE PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
#else
#define PTHREAD_MUTEX_INIT_VALUE PTHREAD_RECURSIVE_MUTEX_INITIALIZER
#endif /* HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP */
#if defined(HAVE_PTHREAD_MUTEX_RECURSIVE_NP)
#define AST_MUTEX_KIND PTHREAD_MUTEX_RECURSIVE_NP
#else
#define AST_MUTEX_KIND PTHREAD_MUTEX_RECURSIVE
#endif /* HAVE_PTHREAD_MUTEX_RECURSIVE_NP */
{code}
The latter also works for Cygwin, since Cygwin only supports the _NP initializer but not the _NP flag.
Comments:By: Rusty Newton (rnewton) 2015-03-24 18:04:19.227-0500

Manuel, do you want to submit a patch? The issue will get addressed much faster that way. You can follow the same process I linked on your other issue.

Thanks!



By: Manuel Meitinger (meitinger) 2015-03-26 10:55:34.031-0500

Thanks for your response. If a patch is necessary to get this issue addressed/fixed, I'll alter the patch of my other issue to include the proper fix mentioned in this issue's description (and not just an {{#ifdef ___CYGWIN___ ...}}) before sending it to the review board.

By: Rusty Newton (rnewton) 2015-04-13 14:43:51.808-0500

If the issues is not affecting dozens or hundreds of people then a patch is often the difference between a fix making it in or it languishing in the tracker until someone finds interest in it. So, a patch is always great! There are hundreds of other issues taking up the core team and community developer's time. They can use all the help they can get. :)

If you decide to add the fix for this issue to a patch on another issue then please let me know and I'll link the two.

By: Asterisk Team (asteriskteam) 2020-12-29 08:04:11.402-0600

Cygwin is no longer a platform being supported by any individual or being persued, so I am closing out this issue.