BUG/MEDIUM: wdt: don't trigger the watchdog when p is unitialized

In wdt_handler(), does not try to trigger the watchdog if the
prev_cpu_time wasn't initialized.

This prevents an unexpected trigger of the watchdog when it wasn't
initialized yet. This case could happen in the master just after loading
the configuration. This would show a trace where the <diff> value is equal
to the <now> value in the trace, and the <poll> value would be 0.

For example:

    Thread 1 is about to kill the process.
    *>Thread 1 : id=0x0 act=1 glob=1 wq=0 rq=0 tl=0 tlsz=0 rqsz=0
                  stuck=1 prof=0 harmless=0 wantrdv=0
                  cpu_ns: poll=0 now=6005541706 diff=6005541706
                  curr_task=0

Thanks to Christian Ruppert for repporting the problem.

Could be backported in every stable versions.
This commit is contained in:
William Lallemand 2022-05-13 11:03:39 +02:00
parent 60cfe8b823
commit ae053b30da

View File

@ -74,8 +74,10 @@ void wdt_handler(int sig, siginfo_t *si, void *arg)
p = ha_thread_ctx[thr].prev_cpu_time;
n = now_cpu_time_thread(thr);
/* not yet reached the deadline of 1 sec */
if (n - p < 1000000000UL)
/* not yet reached the deadline of 1 sec,
* or p wasn't initialized yet
*/
if (!p || n - p < 1000000000UL)
goto update_and_leave;
if ((threads_harmless_mask|sleeping_thread_mask|threads_to_dump) & (1UL << thr)) {