[asterisk-bugs] [Asterisk 0011116]: [patch] *BSD mutex lock issue

noreply at bugs.digium.com noreply at bugs.digium.com
Wed Jun 4 08:28:37 CDT 2008


The following issue has been CLOSED 
====================================================================== 
http://bugs.digium.com/view.php?id=11116 
====================================================================== 
Reported By:                ys
Assigned To:                russell
====================================================================== 
Project:                    Asterisk
Issue ID:                   11116
Category:                   Core/Portability
Reproducibility:            sometimes
Severity:                   minor
Priority:                   normal
Status:                     closed
Asterisk Version:           1.6.0-beta8 
SVN Branch (only for SVN checkouts, not tarball releases):  1.4  
SVN Revision (number only!): 87498 
Disclaimer on File?:        N/A 
Request Review:              
Resolution:                 fixed
Fixed in Version:           
====================================================================== 
Date Submitted:             10-30-2007 09:04 CDT
Last Modified:              06-04-2008 08:28 CDT
====================================================================== 
Summary:                    [patch] *BSD mutex lock issue
Description: 
This is BSD specific issue.

If asterisk compiled on BSD, then used AST_MUTEX_INIT_W_CONSTRUCTORS
definition.
In this case asterisk used gcc constructor/destructor for creation
statically defined mutexes and linklists.

linklist struct may depend at external mutexes, by calling some function
what use it (lock/unlock).
And. But constructor order of calls is unknown (chaotic), some statically
mutex can be uninitialized at
the moment when these function was called.
In result we got sigfault in BSD, when ast_mutex_lock/ast_mutex_unlock are
called with uninitialized
mutexes (reference to NULL pointer), except Linux (where used reference to
structure) ast_mutex_lock
can use uninitialized mutex object.

The same may be applied to orders of destructors functions call.

As result I periodically see "Segmentation fault (core dumped)", mainly at
load/unload/reload CLI commands.

To resolve this problem, as one of the possible ways: init uninitialized
mutex on first request,
as in linux system for statically defined mutexes. 

I upload the diff where realize these (BSD platform).
If someone tries to use not initialized mutex, initialize them.
If called init for already initialized mutex, function simply exit.
If try to destroy uninitialized mutex, function simply exit.

Also, I add some debug stuff into rwlock processing, if compiled with
DEBUG_THREADS option.


Path affected this file:
include/asterisk/lock.h
====================================================================== 

---------------------------------------------------------------------- 
 mvanbaak - 06-04-08 08:28  
---------------------------------------------------------------------- 
closed on reporters request 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
06-04-08 08:28  mvanbaak       Status                   assigned => closed  
06-04-08 08:28  mvanbaak       Note Added: 0087784                          
======================================================================




More information about the asterisk-bugs mailing list