From 3a01553871713888812f234b62a40e892f9f2b8c Mon Sep 17 00:00:00 2001
From: Igor Zhbanov <i.zhbanov@samsung.com>
Date: Tue, 15 Oct 2013 14:35:13 +0400
Subject: [PATCH] Fix for SIGSEGV in systemd-bootchart on short-living
processes
The function svg_ps_bars() dereferencess NULL pointer in the line
endtime = ps->last->sampledata->sampletime;
because of partially initialized ps_struct (ps->last == NULL).
If some process terminates between scaning /proc directory in the log_sample()
function and reading additional information from /proc/PID/... files,
the files couldn't be read, the loop will be continued and partially
initialized structure returned.
---
src/bootchart/store.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/bootchart/store.c b/src/bootchart/store.c
index f8c97c2..7f86cfe 100644
--- a/src/bootchart/store.c
+++ b/src/bootchart/store.c
@@ -275,7 +275,7 @@ schedstat_next:
pscount++;
/* mark our first sample */
- ps->first = ps->sample;
+ ps->first = ps->last = ps->sample;
ps->sample->runtime = atoll(rt);
ps->sample->waittime = atoll(wt);