[Boost-bugs] [Boost C++ Libraries] #5372: spinlock fails on iPad2

Subject: [Boost-bugs] [Boost C++ Libraries] #5372: spinlock fails on iPad2
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-03-25 15:34:05


#5372: spinlock fails on iPad2
-------------------------------+--------------------------------------------
 Reporter: Trantec@… | Owner:
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
  Version: Boost 1.45.0 | Severity: Problem
 Keywords: |
-------------------------------+--------------------------------------------
 Hi,

 I found an issue with the spinlock in spinlock_gcc.hpp.

 In our Project and in my testcode it doesn't work with multithreading on
 the iPad2 multicored arm processor.

 Here is the code which you can use to verify it:

 -----------

 void doSomething(boost::weak_ptr<int> weakp, int* number)
 {
         int i = 0;
         while(++i<10000)
         {
                 {
                         /* That works: the result is a number that equals
 to 40000*/
                         /*__sync_fetch_and_add(number, 1);*/

                         /* Here the result is a number much smaller then
 40000*/
                         /*boost::detail::atomic_increment(number);*/

                         /* This crashes after some time since the
 use_count is becoming zero*/
                         /*boost::shared_ptr<int> p=weakp.lock();*/
                 }
         }
 }*/

 int main(int argc, char *argv[])
 {
         int iNumber = 0;
         boost::shared_ptr<int> p(new int(0));
         boost::shared_array<boost::thread> t;
         t.reset(new boost::thread[4]);
         for(size_t i=0; i<4; i++)
         {
                 t[i] = boost::thread(boost::bind(&doSomething, p,
 &iNumber));
         }

         t[0].join();
         t[1].join();
         t[2].join();
         t[3].join();
 }

 -------

 If you got any questions, don't hasitate writing an email to me :)

 Greetings,

 Sascha

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5372>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC