This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libgcj/33479] SyncTest Intermittent failing on MIPS
- From: "daney at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Sep 2007 23:35:50 -0000
- Subject: [Bug libgcj/33479] SyncTest Intermittent failing on MIPS
- References: <bug-33479-7151@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from daney at gcc dot gnu dot org 2007-09-18 23:35 -------
The LOCKED bit is set. All the other fields in the hash entry are zero.
I think adding a memory barrier at the end of compare_and_swap fixes the
problem.
Currently I have:
inline static bool
compare_and_swap(volatile obj_addr_t *addr,
obj_addr_t old,
obj_addr_t new_val)
{
bool b = __sync_bool_compare_and_swap(addr, old, new_val);
__sync_synchronize();
return b;
}
inline static bool
compare_and_swap_release(volatile obj_addr_t *addr,
obj_addr_t old,
obj_addr_t new_val)
{
return __sync_bool_compare_and_swap(addr, old, new_val);
}
I would have thought that the 'sc' instruction emitted by
__sync_bool_compare_and_swap made the swap visible to other CPUs, but it
appears that the 'sync' emitted by __sync_synchronize() is required. Hmm.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33479