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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/24/2015 04:06 PM, Kyle Harper wrote:
> I understand that double-free()ing is a fatal access violate, however
> this shouldn't be happening in the first place.  I am using pthread
> primitives (mutexes) to guard the critical section wherein I first
> free, then set to NULL the pointer that both threads are looking at.
> The first thread to reach the critical section should (and does)
> free() and NULL, then asserts that *buf == NULL.  The second thread to
> reach the critical section should return without performing any action
> because of the if(*buf == NULL).... section, but it doesn't.

No, you're not.  In the example you just posted only one buffer
is ever allocated and you free it twice.

Andrew.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux