Skip to contentSkip to conversation

stat: fix --bandwidth-log segfault

PATCH In review Igor Konopko 2 participants 2 messages Jun 8, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stat: fix --bandwidth-log segfault

Since bandwidth log has no corresponding thread data and pending struct, we cannot access any fields inside it.

---
 stat.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
stat.c +5 -3
index c89a7f06..1ec2849c 100644
@@ -2212,12 +2212,14 @@ static struct io_logs *get_cur_log(struct io_log *iolog)
 	 * submissions, flag 'td' as needing a log regrow and we'll take
 	 * care of it on the submission side.
 	 */
-	if (iolog->td->o.io_submit_mode == IO_MODE_OFFLOAD ||
+	if ((iolog->td && iolog->td->o.io_submit_mode == IO_MODE_OFFLOAD) ||
 	    !per_unit_log(iolog))
 		return regrow_log(iolog);
 
-	iolog->td->flags |= TD_F_REGROW_LOGS;
-	assert(iolog->pending->nr_samples < iolog->pending->max_samples);
+	if (iolog->td)
+		iolog->td->flags |= TD_F_REGROW_LOGS;
+	if (iolog->pending)
+		assert(iolog->pending->nr_samples < iolog->pending->max_samples);
 	return iolog->pending;
 }
 
Signature · 1 line
2.14.3
#1 lore raw
Quoted 2 lines · Igor Konopko

Since bandwidth log has no corresponding thread data and pending struct, we cannot access any fields inside it.

Thanks Igor, applied.

Signature · 1 line
Jens Axboe