This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unexpected value-at for NULL'd pointer with pthreads


On 21 August 2015 at 19:25, Jeffrey Walton wrote:
> From the sounds of it, it sounds like its the same issue that used to
> occur with the double-checked locking initialization pattern. See, for
> example, http://preshing.com/20130930/double-checked-locking-is-fixed-in-cpp11/.

Except that nothing is read outside the critical section guarded by the mutex.

> If this is the case, then use a memory barrier to ensure the write
> completes after setting the pointer to NULL.

pthread_mutex_unlock should be a release operation and
pthread_mutex_lock should be an acquire operation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]