[cfe-dev] libc++ mutex destructor assertion

Chandler Carruth chandlerc at google.com
Fri Jun 13 10:34:27 PDT 2014


On Fri, Jun 13, 2014 at 6:32 PM, David Majnemer <david.majnemer at gmail.com>
wrote:

> It is very reasonable for this to be UB.  Imagine a mutex where memory is
> allocated in pthread_mutex_init and free'd in pthread_mutex_destroy.
>  Unlocks which race with the destruction may end up partying on free'd
> memory.
>
>
>>
>> It's very easy to support this -- just don't call
>> pthread_mutex_destroy(), the function has no purpose really.
>>
>
> This is not true. Some implementations, like FreeBSD's libthr, free memory
> in their pthread_mutex_destroy.  Not calling pthread_mutex_destroy will
> lead to leaks.
>

This ... makes me extremely sad. It makes mutexes significantly more
annoying to use in a bunch of patterns if you cannot destroy them while
locked.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140613/a9e2e1e0/attachment.html>


More information about the cfe-dev mailing list