[MPlayer-dev-eng] GetTimerMS overflow

Jarek Czekalski jarekczek at poczta.onet.pl
Sun Mar 2 18:03:44 CET 2014


Hi devs

While working on the bug #2174 [1] I discovered that timestamp handling 
in mplayer is probably broken.

1. It is vulnerable to time changes (daylight saving) twice a year
2. It suffers from overflows

Ad. 1
Monotonic clock should be used instead of real time clock. That is 
get_clocktime(CLOCK_MONOTONIC) [2] instead of gettimeofday [3]

Ad. 2
long long values should hold number of milli- and microseconds, as it is 
done in stream/tvi_v4l2.c. The private library function GetTimerMS 
(osdep/timer-linux.c) uses unsigned int for this purpose. This easily 
overflows, because current time in seconds is 1 393 778 888, which 
hardly fits in 32-bit integer. After multiplying by 1K or 1M we are 
overflowed. If my calculations are correct, that means GetTimerMS starts 
from 0 every 4000 seconds.

I would like to know what steps do you suggest to solve these problems. 
Should I send a patch to fix that?

Best
Jarek

[1] https://trac.mplayerhq.hu/ticket/2174
[2] http://linux.die.net/man/3/clock_gettime
[3] http://linux.die.net/man/2/gettimeofday



More information about the MPlayer-dev-eng mailing list