[tarantool-patches] Re: [PATCH] memtx: cancel checkpoint thread at exit

Vladimir Davydov vdavydov.dev at gmail.com
Thu Apr 18 21:23:48 MSK 2019


On Thu, Apr 18, 2019 at 08:24:55PM +0300, Konstantin Osipov wrote:
> * Vladimir Davydov <vdavydov.dev at gmail.com> [19/04/18 20:19]:
> > On Thu, Apr 18, 2019 at 06:46:54PM +0300, Vladimir Davydov wrote:
> > > +static void
> > > +checkpoint_cancel(struct checkpoint *ckpt)
> > > +{
> > > +	/*
> > > +	 * Cancel the checkpoint thread if it's running and wait
> > > +	 * for it to terminate so as to eliminate the possibility
> > > +	 * of use-after-free.
> > > +	 */
> > > +	if (ckpt->cord.id != 0 &&
> > > +	    tt_pthread_cancel(ckpt->cord.id) != ESRCH)
> > > +		tt_pthread_join(ckpt->cord.id, NULL);
> > > +	checkpoint_delete(ckpt);
> > > +}
> > 
> > Oops, turned out this check isn't quite correct as we don't reset
> > cord.id after joining the thread. As a result, we might call
> > pthread_cancel on an already joined thread, which leads to a crash
> > (caught by Travis CI):
> 
> I would reset cord.id instead.

Umm, no - the flag is already there and is used for the same purpose so
I don't see any point in resetting cord.id. Anyway, it's a bikeshed.
Pushed as is to master.



More information about the Tarantool-patches mailing list