zk-phi / symon

Tiny graphical system monitor
289 stars 26 forks source link

Randomly getting `arith-error` #25

Closed kaushalmodi closed 7 years ago

kaushalmodi commented 9 years ago

Hi,

I am running the latest build of emacs from its git master branch.

I noticed that I started getting arith-error errors at random after I installed symon. Here is one case when I can consistently reproduce it.

I use paradox for pacakge management. I get this error some time after I do M-x paradox-list-packages. I have also seen this error show up when I update packages without using paradox.

Here is the error trace:

Debugger entered--Lisp error: (arith-error)
  #[nil "\306\307\310H\311\312\313\314#\211G\315U\203 @\202 \316\317\320GD\"\321\322  \"\323  8\f\205? \f@Z\n\fAZ\211
Z\324_\245*\nB,\"\207" [--cl-rest-- cpu idle total symon-linux--last-cpu-ticks idle-diff ring-insert [(24 50 . [nil 2 1 2 0 0 0 2 5 3 0 0 0 0 2 0 2 0 2 2 1 2 3 0 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil]) [t 21820 20781 462670 3 #0 nil nil 0]] 0 symon-linux--read-lines "/proc/stat" #[(str) "\301\302\303\304\305#\"\207" [str mapcar read split-string nil t] 6] ("cpu") 1 signal wrong-number-of-arguments nil apply + 3 100 total-diff] 7]()
  apply(#[nil "\306\307\310H\311\312\313\314#\211G\315U\203 @\202 \316\317\320GD\"\321\322    \"\323  8\f\205? \f@Z\n\fAZ\211
Z\324_\245*\nB,\"\207" [--cl-rest-- cpu idle total symon-linux--last-cpu-ticks idle-diff ring-insert [(24 50 . [nil 2 1 2 0 0 0 2 5 3 0 0 0 0 2 0 2 0 2 2 1 2 3 0 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil]) [t 21820 20781 462670 3 #0 nil nil 0]] 0 symon-linux--read-lines "/proc/stat" #[(str) "\301\302\303\304\305#\"\207" [str mapcar read split-string nil t] 6] ("cpu") 1 signal wrong-number-of-arguments nil apply + 3 100 total-diff] 7] nil)
  timer-event-handler([t 21820 20781 462670 3 #[nil "\306\307\310H\311\312\313\314#\211G\315U\203 @\202 \316\317\320GD\"\321\322  \"\323  8\f\205? \f@Z\n\fAZ\211
Z\324_\245*\nB,\"\207" [--cl-rest-- cpu idle total symon-linux--last-cpu-ticks idle-diff ring-insert [(24 50 . [nil 2 1 2 0 0 0 2 5 3 0 0 0 0 2 0 2 0 2 2 1 2 3 0 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil]) #0] 0 symon-linux--read-lines "/proc/stat" #[(str) "\301\302\303\304\305#\"\207" [str mapcar read split-string nil t] 6] ("cpu") 1 signal wrong-number-of-arguments nil apply + 3 100 total-diff] 7] nil nil 0])
FrancisMurillo commented 7 years ago

My money is on line 394, division by zero.

(/ (* (- total-diff idle-diff) 100) total-diff)

A simple fix would be

(if (zerop total-diff) 0 (/ (* (- total-diff idle-diff) 100) total-diff))
zk-phi commented 7 years ago

Thanks, I'll try that!