Comment 243 for bug 1220426

Revision history for this message
In , Aaron Plattner (aplattner) wrote :

Yeah, it should. Thanks for the ping.

Marking fixed with commit fe4c774c572e3f55a7417f0ca336ae1479a966ad
Author: Nikhil Mahale <email address hidden>
Date: Sat Jan 24 17:06:59 2015 -0800

    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.

    Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=86288
    Signed-off-by: Nikhil Mahale <email address hidden>
    Reviewed-by: Julien Cristau <email address hidden>

    v2: Apply warning fixes from Keith Packard <email address hidden>

    Reviewed-by: Aaron Plattner <email address hidden>
    Signed-off-by: Aaron Plattner <email address hidden>
    Signed-off-by: Keith Packard <email address hidden>

 os/WaitFor.c | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)