Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

std::string ref count problem

807575Apr 28 2004 — edited Nov 7 2004
I'm developing a huge multi-threaded application, in which many many threads access
a string object simultaneously. The program runs normally for few hours, but suddenly
it crashes with SEGV.

I've found that the reference count value of the string object is incorrect at the time of crash.
I investigated more and came to the fact that the guard mechanism for the reference count
differs between in the copy constructor and in the assignment operator of the string.
The former is instantiated in my application code and it uses mutex for guarding the reference
count, the latter is provided by libCstd_isa.so.1 and it uses InterlockedIncrement/Decrement.
Since InterlockedIncrement/Decrement can intrude into the mutex guard, the reference count
value becomes incorrect, I guess.

Some workarounds I thought of are:
1. use -xarch=v8plus option (the program above is compiled with no -x options)
But the application doesn't run on legacy sparc machine.
2. link libCstd.a statically
But the application size becomes large.
3. set LD_NOAUXFLTR environment variable at run time
But libc_psr.so.1 will also not be loaded.

Which (or any other) solution is recommended, or any patches out fix this problem?
I guess libCstd_isa.so.1 should provide the implementation of the copy constructor
using InterlockedIncrement.

Thanks.

OS: Solaris 8 10/00
Compiler: Forte 6 update 2
Patches: 111685-18, 108434-13, 109147-26
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 5 2004
Added on Apr 28 2004
11 comments
347 views