<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 13, 2014 at 6:32 PM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>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.</div>
<div class="">
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">
<div class="gmail_extra"><br></div><div class="gmail_extra">It's very easy to support this -- just don't call pthread_mutex_destroy(), the function has no purpose really.</div></div></blockquote><div><br></div></div>
<div>
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.</div></blockquote></div><br>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.</div>
</div>