I proably found the problem.
debug-on-error has to be on
If you run a timer with an error:
(run-with-timer 0 1 (lambda ()
(print garbage)))
then the backtrace window comes up. If you press q there then you'll have a negative timer
in the list.
This probably is because function timer-event-handler uses condition-case-unless-debug,
so if you press q then you go back to top level and the rest of the code doesn't run.
I understand condition-case-unless-debug is used, so one can debug a timer, but on the
other hand if debug is on for some other reason and the user press q automatically
to get rid of the backtrace window then the timer list will have some garbage in it.