daandemeyer / rpms / systemd

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