Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Konstantin Osipov <kostja@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [tarantool-patches] Re: [PATCH] memtx: cancel checkpoint thread at exit
Date: Thu, 18 Apr 2019 21:23:48 +0300	[thread overview]
Message-ID: <20190418182348.dsdvwqhhhwpqnw4j@esperanza> (raw)
In-Reply-To: <20190418172455.GH13022@chai>

On Thu, Apr 18, 2019 at 08:24:55PM +0300, Konstantin Osipov wrote:
> * Vladimir Davydov <vdavydov.dev@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.

  reply	other threads:[~2019-04-18 18:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-18 15:46 Vladimir Davydov
2019-04-18 17:15 ` Vladimir Davydov
2019-04-18 17:24   ` [tarantool-patches] " Konstantin Osipov
2019-04-18 18:23     ` Vladimir Davydov [this message]
2019-04-18 17:24 ` Konstantin Osipov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190418182348.dsdvwqhhhwpqnw4j@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] Re: [PATCH] memtx: cancel checkpoint thread at exit' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox