lthread
lthread copied to clipboard
Incorrect time calculation in scheduler on 32 bit systems
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.
I must notice, that to confirm & fix this bug, only a few things required:
- gdb
- 32 bit box
- change one line of code
Which of them is causing the trouble?