From: Jérémie Galarneau Date: Sat, 7 Jan 2017 17:32:13 +0000 (-0500) Subject: Fix: lock nesting order reversed X-Git-Tag: v2.9.2~2 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=a23ca18428f7e2b8bece8d3f47a9c274cf030ec4;p=lttng-tools.git Fix: lock nesting order reversed The lttng_consumer_stream lock must nest INSIDE the metadata cache lock, as indicated in the structure's comments (see consumer.h:340). CID 1368314 (#1 of 1): Thread deadlock (ORDER_REVERSAL) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/consumer/consumer.c b/src/common/consumer/consumer.c index 54a0531d5..234944dad 100644 --- a/src/common/consumer/consumer.c +++ b/src/common/consumer/consumer.c @@ -2051,8 +2051,8 @@ void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, DBG3("Consumer delete metadata stream %d", stream->wait_fd); pthread_mutex_lock(&consumer_data.lock); - pthread_mutex_lock(&stream->chan->lock); pthread_mutex_lock(&stream->chan->metadata_cache->lock); + pthread_mutex_lock(&stream->chan->lock); pthread_mutex_lock(&stream->lock); /* Remove any reference to that stream. */ @@ -2078,8 +2078,8 @@ void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, stream->chan->metadata_stream = NULL; pthread_mutex_unlock(&stream->lock); - pthread_mutex_unlock(&stream->chan->metadata_cache->lock); pthread_mutex_unlock(&stream->chan->lock); + pthread_mutex_unlock(&stream->chan->metadata_cache->lock); pthread_mutex_unlock(&consumer_data.lock); if (free_chan) {