Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / September 2005



Tip: Looking for answers? Try searching our database.

Crash with Boost 1.33.0 shared_ptr's and MSL carbon

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
acronce@gmail.com - 15 Sep 2005 19:55 GMT
Hi all,

I just updated from boost 1.32.0 to 1.33.0 and am seeing crashes in my
carbon/MSL application. Here's some test code that demonstrates the
crash:

    _tprintf(_T("\nTest a vector of boost shared_ptr's:\n"));
    typedef boost::shared_ptr<std::string>        SharedPtrString;
    typedef vector<SharedPtrString>            StringContainer;
    typedef vector<SharedPtrString>::iterator        StringContainerIterator;

    {
    SharedPtrString    sharedPtrString1(new std::string("Hi there!"));
    SharedPtrString    sharedPtrString2(new std::string("Hi there!"));

    _tprintf( _T("  sharedPtrString1->c_str() = \"%s\"\n"),
sharedPtrString1->c_str() );
    _tprintf( _T("  sharedPtrString2->c_str() = \"%s\"\n"),
sharedPtrString2->c_str() );
    }

    // We never get here because of an access error

Basically when the SharedPtrString goes out of scope, I get an access
error. Has anyone else had luck with this version of Boost and
MSL/Carbon? Maybe I'm missing a config setting that's new to this
version?

Best regards,
--
Allen Cronce
James W. Walker - 16 Sep 2005 07:06 GMT
> I just updated from boost 1.32.0 to 1.33.0 and am seeing crashes in my
> carbon/MSL application.

Yes, I too had crashes in shared pointer code when using boost 1.33.
Then I updated to even newer boost code obtained by CVS, and the
crashes went away.
Howard Hinnant - 22 Sep 2005 20:32 GMT
> > I just updated from boost 1.32.0 to 1.33.0 and am seeing crashes in my
> > carbon/MSL application.
>
> Yes, I too had crashes in shared pointer code when using boost 1.33.
> Then I updated to even newer boost code obtained by CVS, and the
> crashes went away.

Just fyi, off the boost mailing list:

On Aug 21, 2005, at 4:56 PM, Howard Hinnant wrote:

On Aug 21, 2005, at 4:28 PM, Steve Ramsey wrote:

> I've had a number of programs crash after recompiling with the 1.33.0
> release and eventually tracked the problems down to shared_ptr,
> specifically the atomic_decrement function provided in
> sp_counted_base_cw_ppc.hpp.

Try these:

inline void atomic_increment( register long * pw )
{
    register int a;
    asm
    {
loop:

    lwarx   a, 0, pw
    addi    a, a, 1
    stwcx.  a, 0, pw
    bne-    loop
    }
}

inline long atomic_decrement( register long * pw )
{
    register int a;
    asm
    {
    sync

loop:

    lwarx   a, 0, pw
    addi    a, a, -1
    stwcx.  a, 0, pw
    bne-    loop

    isync
    }
    return a;
}

inline long atomic_conditional_increment( register long * pw )
{
    register int a;
    asm
    {
loop:

    lwarx   a, 0, pw
    cmpwi   a, 0
    beq     store

    addi    a, a, 1

store:

    stwcx.  a, 0, pw
    bne-    loop

    }
    return a;
}

-Howard

On Aug 23, 2005, at 10:32 AM, Howard Hinnant wrote:

On Aug 23, 2005, at 4:50 AM, Ben Artin wrote:

> I consider
> this a pretty serious error, and that I think we should understand how
> it came
> to pass.

The technical cause of the error is that there was an unforeseen
conflict between the CodeWarrior compiler's register allocation scheme,
and the original code, but only when the original was actually inlined
(the conflict disappeared with inlining off as might have easily
happened in a debug run).  The bug had nothing to do with
multithreading or memory barriers per say, just that these issues were
what was being implemented.

The fix was to avoid explicitly naming registers in the assembly,
allowing the compiler to allocate registers at will with no chance for
conflict.

The bug was first detected (to my knowledge) by John Daub on Aug. 10.  
I learned about it on Aug. 12, but was not able to look at it, diagnose
it, and suggest a fix until Aug. 15.

<shrug> bugs happen.  Bugs of this nature won't be eradicated unless
you outlaw dropping into assembly (and I don't recommend that).

Perhaps an extended public beta of boost releases (all compressed and
easy to download) might help?

-Howard
Ben Artin - 16 Sep 2005 10:31 GMT
> I just updated from boost 1.32.0 to 1.33.0 and am seeing crashes in my
> carbon/MSL application. Here's some test code that demonstrates the
> crash:

Boost 1.33.0 is broken on Mac OS X. There's a bug in shared_ptr. 1.33.1 is being
worked on; in the meanwhile, you can either back out to 1.32.0 or you need to
download the current boost sources.

hth

Ben

Signature

If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>

I changed my name: <http://periodic-kingdom.org/People/NameChange.php>

acronce@gmail.com - 16 Sep 2005 16:26 GMT
Thanks James and Ben! I did a CVS checkout this morning and it resolved
the crash.

But what's disturbing here is that a crashing bug in shared_ptr (which
I assume is extremely popular) would find its way in to an official
release. It would seem to indicate that boost is not tested on Mac OS
X. Or maybe CodeWarrior's MSL is not tested, which I could kind of
understand given the way the winds have been blowing lately.

Also disturbing is that no one on the boost list seemed to know about
this crash. I had to get the answer here.

Am I off base here, or does the boost team not test on Mac OS X?

Best,
--
Allen Cronce
Ben Artin - 16 Sep 2005 20:20 GMT
> But what's disturbing here is that a crashing bug in shared_ptr (which
> I assume is extremely popular) would find its way in to an official
> release.

I agree and I have expressed my opinion on the boost list after this bug was
found.

> It would seem to indicate that boost is not tested on Mac OS X

This bug only shows up with some compiler settings, and those settings were not
in the regression suite for Mac OS X. Boost is tested on Mac OS X.

hth

Ben

Signature

If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>

I changed my name: <http://periodic-kingdom.org/People/NameChange.php>

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.