lthread icon indicating copy to clipboard operation
lthread copied to clipboard

Incorrect time calculation in scheduler on 32 bit systems

Open wisd0me opened this issue 11 years ago • 1 comments

There is a bug in integer addition in _lthread_usec_now(): signed long time_t overflows. The return statement must look like this:

/* _lthread_usec_now(): */
    return (uint64_t) t1.tv_sec * 1000000 + t1.tv_usec;

Bug shows itself as follows - after some point in time lthread functions with timeouts start trashing the cpu, in my case it was lthread_read(). I've found this after I was unable to recover seconds from sched->birth on my 32bit box.

wisd0me avatar Sep 02 '14 10:09 wisd0me

I must notice, that to confirm & fix this bug, only a few things required:

  1. gdb
  2. 32 bit box
  3. change one line of code

Which of them is causing the trouble?

wisd0me avatar Nov 26 '14 08:11 wisd0me