libstdc++/5037: Multithreaded read access to strings not threadsafe on Solaris/Sparc
Loren James Rittle
rittle@latour.rsch.comm.mot.com
Thu Dec 6 16:33:00 GMT 2001
> I believe this file [libstdc++-v3/config/cpu/sparc/*/bits/atomicity.h]
> is broken. __exchange_and_add and __atomic_add use separate locks,
> and so are not protected from each other.
[CC'ing libstdc++ list.]
Yikes! I see exactly what you are saying. I found WWW documentation
on the machine-level locking primitive used on sparc and I completely
concur with your finding. For the record, the i386 atomicity.h file
uses an architecture primitive that requires no such extra memory
word. People have reported failures on sparc that have been
unexplainable and unseen on other platforms (offhand, I don't recall
if they involved multiple processors but I think I understand how this
problem could nail even a single processor). You surely have helped
to solve a major mystery (in my mind at least).
Any best solution (in terms of contention) requires a locking word
related to the first argument. Would a designer of the atomicity.h
abstraction layer prefer to provide such a solution?
I think anyone could provide a correct fix that would suffer
contention... ;-) With my observation above, I think anyone could
provide an efficient solution. I know I could do either in minutes.
IMHO, the trick is going to be fixing this problem without changing
the abstraction layer... We also need to check all other
libstdc++-v3/config/cpu/.../bits/atomicity.h files for this issue.
Regards,
Loren
More information about the Libstdc++
mailing list