[PATCH] fix race condition in List_insert

Александр Маликов schn27@gmail.com
Mon Aug 23 15:48:21 GMT 2021


https://gist.github.com/schn27/23b47563b429aaaad5ac315d05a43a11

The test is failed if "Thread #X timeout" is printed and -1 returned. This
happens on my laptop in about several minutes.
The test is passed if it runs infinitely.


пн, 23 авг. 2021 г. в 18:02, Corinna Vinschen <corinna-cygwin@cygwin.com>:

> Hi Aleksandr,
>
>
> thanks for the patch.
>
> On Aug 23 17:27, Aleksandr Malikov wrote:
> > From: Aleksand Malikov <schn27@gmail.com>
> >
> > Revert mx parameter and mutex lock while operating the list.
> > Mutex was removed with 94d24160 informing that:
> > 'Use InterlockedCompareExchangePointer to ensure race safeness
> > without using a mutex.'
> >
> > But it does not.
> >
> > Calling pthread_mutex_init and pthread_mutex_destroy from two or
> > more threads occasionally leads to hang in pthread_mutex_destroy.
>
> Do you have a simple testcase in plain C, by any chance?
>
> > To not change the behaviour of other cases where List_insert was called,
> > List_insert_nolock is added.
>
> LGTM.  Can you please provide a copyright waiver per
> https://cygwin.com/contrib.html.  See the winsup/CONTRIBUTORS file.
>
>
> Thanks,
> Corinna
>


More information about the Cygwin-patches mailing list