reassign 388702 librep
tag 388702 upstream patch
thanks

Hi Christian,

This bug, originally reported to sawfish, was traced by people on
sawfish-list to inside librep. It seems that the patch will be mandatory
in future kernels. Since I don't know if upstream will be updated to
include this patch, I forward it to you.

----- Forwarded message from Michal Jaegermann <[EMAIL PROTECTED]> -----

Subject: setitimer will need a range check
From: Michal Jaegermann <[EMAIL PROTECTED]>
Date: Tue, 26 Dec 2006 17:35:06 -0700
To: [email protected]

The current version of 'man setitimer' for Linux says the following:

       POSIX.1-2001 says that setitimer() should fail if a  tv_usec  value  is
       specified  that  is  outside  of the range 0 to 999999.  However, Linux
       does not give an error, but instead silently adjusts the  corresponding
       seconds value for the timer.  In the future (scheduled for March 2007),
       this non-conformance will be repaired: existing applications should  be
       fixed now to ensure that they supply a properly formed tv_usec value.

With a library which is current enough I am seeing such entries
in log files:

setitimer: sawfish (pid = 3894) provided invalid timeval it_value:
tv_sec = 59 tv_usec = 1000000

To satisfy the above the follwing change in librep would do:

--- librep/src/timers.c.itimer  2002-03-01 22:22:53.000000000 -0700
+++ librep/src/timers.c 2006-12-26 17:00:14.000000000 -0700
@@ -106,9 +106,12 @@ setup_next_timer (void)
     {
 #ifdef HAVE_SETITIMER
        struct itimerval it, tem;
+       long usec;
        it.it_interval.tv_usec = 0;
        it.it_interval.tv_sec = 0;
-       it.it_value.tv_usec = timer_chain->rel_msecs * 1000;
+       usec = timer_chain->rel_msecs * 1000;
+       usec = usec < 1000000 ? (usec < 0 ? 0 : usec ) : 999999;
+       it.it_value.tv_usec = usec;
        it.it_value.tv_sec = timer_chain->rel_secs;
        setitimer (ITIMER_REAL, &it, &tem);
 #else

Strictly speaking one should likely reduce the range for tv_usec and
adjust tv_sec value accordingly, ie. 60 and 0 in the situation recorded
in logs, but in practice the above should likely be enough.

   Michal

----- End forwarded message -----

-- 
Rodrigo Gallardo
GPG-Fingerprint: 7C81 E60C 442E 8FBC D975  2F49 0199 8318 ADC9 BC28
Zenophobia: the irrational fear of convergent sequences.

Attachment: signature.asc
Description: Digital signature

Reply via email to