[PATCH] os: Fix timer race conditions

Aaron Plattner aplattner at nvidia.com
Mon Dec 29 08:16:12 PST 2014


On 12/01/2014 04:59 AM, Julien Cristau wrote:
> On Wed, Nov 26, 2014 at 12:20:03 +0530, Nikhil Mahale wrote:
>
>>  From 5c797ce9cdb596107f9ebcdf8345ca234c587b22 Mon Sep 17 00:00:00 2001
>> From: Nikhil Mahale <nmahale at nvidia.com>
>> Date: Tue, 11 Nov 2014 17:44:28 +0530
>> Subject: [PATCH] os: Fix timer race conditions
>>
>> Fixing following kind of race-conditions -
>>
>>      WaitForSomething()
>>      |
>>      ---->  // timers -> timer-1 -> timer-2 -> null
>>             while (timers && (int) (timers->expires - now) <= 0)
>>                 // prototype - DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev)
>>                 DoTimer(timers, now, &timers)
>>                 |
>>                 |
>>                 ----> OsBlockSignals();  .... OS Signal comes just before blocking it,
>>                                          .... timer-1 handler gets called.
>>                                               // timer-1 gets served and scheduled again;
>>                                               // timers -> timer-2 -> timer-1 -> null
>>                                          ....
>>                       *prev = timer->next;
>>                        timer->next = NULL;   // timers -> null
>>                        // timers list gets corrupted here and timer-2 gets removed from list.
>>
>> https://bugs.freedesktop.org/show_bug.cgi?id=86288
>> Signed-off-by: Nikhil Mahale <nmahale at nvidia.com>
>> ---
>>   os/WaitFor.c | 31 ++++++++++++++++++++-----------
>>   1 file changed, 20 insertions(+), 11 deletions(-)
>>
> Reviewed-by: Julien Cristau <jcristau at debian.org>

Keith, any chance of getting this in for 1.17?  I know you expressed 
reservations about it, but the current code definitely corrupts the 
timer list and is affecting a bunch of people, so this patch is 
certainly better than nothing.

-- Aaron


More information about the xorg-devel mailing list