Tarantool development patches archive
 help / color / mirror / Atom feed
From: Konstantin Osipov <kostja@tarantool.org>
To: tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH] memtx: cancel checkpoint thread at exit
Date: Thu, 18 Apr 2019 20:24:55 +0300	[thread overview]
Message-ID: <20190418172455.GH13022@chai> (raw)
In-Reply-To: <20190418171551.5zfqurxnyrdkwxjj@esperanza>

* 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.

-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

  reply	other threads:[~2019-04-18 17:24 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   ` Konstantin Osipov [this message]
2019-04-18 18:23     ` [tarantool-patches] " Vladimir Davydov
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=20190418172455.GH13022@chai \
    --to=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[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