[asterisk-dev] Error msg: Asterisk is not Thread safe

Russell Bryant russell at digium.com
Sun Dec 7 08:47:05 CST 2008


On Dec 6, 2008, at 5:23 PM, Tilghman Lesher wrote:

> This appears to be a problem on Ubuntu 8.04 and 8.10, while 7.10 is  
> okay.
> Also, Debian Lenny does not appear to manifest this issue.  Of note  
> is that
> Ubuntu 7.10 uses glibc version 2.6.1, while 8.04 and 8.10 both use  
> glibc 2.7.
> It would be helpful for several people on different distributions to  
> run this
> testcase program, and report back the distribution name, version,  
> and glibc
> version on that machine.  My suspicion is that this is either a  
> glibc issue
> that Debian has fixed and has not made its way into Ubuntu yet, or  
> else
> Ubuntu introduced this problem downstream of Debian.  Knowing whether
> other distributions on glibc 2.7 also have this issue will help us  
> isolate
> the cause.


Before we go off chasing version issues, let's take a look at the  
code.  At first glance, the test seems invalid.

The test runs two threads, both tweaking the value of the same  
integer.  The two functions that run in parallel are  
test_thread_body() and test_for_thread_safety().

test_thread_body() modifies the integer with only test_lock held, and  
then later, with only test_lock2 held.

test_for_thread_safety() modifies the integer with both test_lock and  
test_lock2 held, and at one point, only with test_lock2 held.

The problem is that one thread assumes it can modify the integer with  
only test_lock held, and the other assumes it can modify it with only  
test_lock2 held.  This could cause valid errors to occur in the test.

--
Russell Bryant
Senior Software Engineer
Open Source Team Lead
Digium, Inc.







More information about the asterisk-dev mailing list