ref: eb6a4fc1a4a6e32cd35e76771fe8687b64e9122f
parent: c8cf0cee47914699e3e7c10a7b7501af94b53b4e
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Sep 27 22:42:33 EDT 2014
devcons: avoid division by zero reading Qsysstat alexchandel got the kernel to crash with divide error on qemu 2.1.2/macosx at this location. probably caused by perfticks()/tsc being wrong or accounttime() not having been called yet from timer interrupt yet for some reason.
--- a/sys/src/9/port/devcons.c
+++ b/sys/src/9/port/devcons.c
@@ -581,13 +581,14 @@
bp += NUMSIZE;
readnum(0, bp, NUMSIZE, mp->load, NUMSIZE);
bp += NUMSIZE;
+ l = mp->perf.period;
+ if(l == 0)
+ l = 1;
readnum(0, bp, NUMSIZE,
- (mp->perf.avg_inidle*100)/mp->perf.period,
- NUMSIZE);
+ (mp->perf.avg_inidle*100)/l, NUMSIZE);
bp += NUMSIZE;
readnum(0, bp, NUMSIZE,
- (mp->perf.avg_inintr*100)/mp->perf.period,
- NUMSIZE);
+ (mp->perf.avg_inintr*100)/l, NUMSIZE);
bp += NUMSIZE;
*bp++ = '\n';
}