From: liguang.li@windriver.com (Liguang Li)
Subject: [lttng-dev] [PATCH lttng-tools] Fix: lttng-consumerd crash due to double free metadata stream
Date: Wed, 27 Sep 2017 17:57:59 +0800 [thread overview]
Message-ID: <1506506279-23472-1-git-send-email-liguang.li@windriver.com> (raw)
When setup metadata failed, the exception handling function will free
the metadata stream twice.
Signed-off-by: Liguang Li <liguang.li at windriver.com>
---
src/common/ust-consumer/ust-consumer.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c
index 366f855..3836ef9 100644
--- a/src/common/ust-consumer/ust-consumer.c
+++ b/src/common/ust-consumer/ust-consumer.c
@@ -234,6 +234,8 @@ static int send_stream_to_thread(struct lttng_consumer_stream *stream,
ERR("Consumer write %s stream to pipe %d",
stream->metadata_flag ? "metadata" : "data",
lttng_pipe_get_writefd(stream_pipe));
+ /* Remove node from the channel stream list. */
+ cds_list_del(&stream->send_node);
if (stream->metadata_flag) {
consumer_del_stream_for_metadata(stream);
} else {
@@ -721,8 +723,6 @@ static int send_streams_to_thread(struct lttng_consumer_channel *channel,
* If we are unable to send the stream to the thread, there is
* a big problem so just stop everything.
*/
- /* Remove node from the channel stream list. */
- cds_list_del(&stream->send_node);
goto error;
}
@@ -925,7 +925,7 @@ static int setup_metadata(struct lttng_consumer_local_data *ctx, uint64_t key)
* a big problem so just stop everything.
*/
ret = LTTCOMM_CONSUMERD_FATAL;
- goto error;
+ goto end;
}
/* List MUST be empty after or else it could be reused. */
assert(cds_list_empty(&metadata->streams.head));
@@ -940,8 +940,14 @@ error:
* the stream is still in the local stream list of the channel. This call
* will make sure to clean that list.
*/
- consumer_stream_destroy(metadata->metadata_stream, NULL);
cds_list_del(&metadata->metadata_stream->send_node);
+
+ /* Destroy tracer buffers of the stream. */
+ consumer_stream_destroy_buffers(metadata->metadata_stream);
+ /* Close down everything including the relayd if one. */
+ consumer_stream_close(metadata->metadata_stream);
+
+ consumer_stream_destroy(metadata->metadata_stream, NULL);
metadata->metadata_stream = NULL;
error_no_stream:
end:
--
2.7.4
next reply other threads:[~2017-09-27 9:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-27 9:57 Liguang Li [this message]
2017-09-28 20:57 ` Jonathan Rajotte-Julien
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=1506506279-23472-1-git-send-email-liguang.li@windriver.com \
--to=liguang.li@windriver.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox