times(2) misbehaviour
Joakim Tjernlund
joakim.tjernlund at transmode.se
Sun Jan 31 21:38:50 UTC 2010
>
> >
> > Hello,
> >
> > after a big bug hunt we also found that the implementation of the
> > "times" system call in uClibc 0.9.29/0.9.30 is problematic on some 32
> > bits architectures (arm926 in our case); like it was reported 2 years
> > ago by Will.
> >
> > The fact that uClibc considers some Linux sys_times() return values as
> > errors makes some user space applications become crazy (Qt in our case):
> > when Linux "times" syscall's return value is inside uClibc errors range
> > (cf INTERNAL_SYSCALL_ERROR_P macro), uClibc forward a (-1) error code to
> > caller. An application may freeze during many seconds (40 if system tick
> > is 10ms), if it's event handling relies on times() accuracy. Problem
> > occurs after 5 minutes of system's running, when Linux tick timer value
> > reaches its limit on 32 bits systems.
>
> Oh yes, been there done that :)
> Most arch's has this bug in linux(ppc in recent 2.6 does not).
Forgot to mention that time(2) has the same problem. Both
times(2) and time(2) was fixed by commit e3d5a27d5862b6425d0879272e24abecf7245105
but not for all arch's:
Allow times and time system calls to return small negative values
At the moment, the times() system call will appear to fail for a period
shortly after boot, while the value it want to return is between -4095 and
-1. The same thing will also happen for the time() system call on 32-bit
platforms some time in 2106 or so.
On some platforms, such as x86, this is unavoidable because of the system
call ABI, but other platforms such as powerpc have a separate error
indication from the return value, so system calls can in fact return small
negative values without indicating an error. On those platforms,
force_successful_syscall_return() provides a way to indicate that the
system call return value should not be treated as an error even if it is
in the range which would normally be taken as a negative error number.
This adds a force_successful_syscall_return() call to the time() and
times() system calls plus their 32-bit compat versions, so that they don't
erroneously indicate an error on those platforms whose system call ABI has
a separate error indication. This will not affect anything on other
platforms.
Joakim Tjernlund added the fix for time() and the compat versions of
time() and times(), after I did the fix for times().
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund at transmode.se>
Signed-off-by: Paul Mackerras <paulus at samba.org>
Acked-by: David S. Miller <davem at davemloft.net>
Cc: Ingo Molnar <mingo at elte.hu>
Cc: Thomas Gleixner <tglx at linutronix.de>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
More information about the uClibc
mailing list