Bug 1139977

Summary: g_timeout_add() timer expires too quickly when the system time is changed
Product: Red Hat Enterprise Linux 6 Reporter: Andrew Beekhof <abeekhof>
Component: glib2Assignee: Colin Walters <walters>
Status: CLOSED WONTFIX QA Contact: Desktop QE <desktop-qa-list>
Severity: high Docs Contact:
Priority: high    
Version: 6.6   
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-06 11:05:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Andrew Beekhof 2014-09-10 06:36:37 UTC
Description of problem:

If the system time is moved forward, timers created with g_timeout_add() expire too soon.  In the wild this occurs frequently when NTP is enabled in a clustering environment as pacemaker (HA Add-on) uses g_timeout_add() extensively.

Apparently this is already fixed in RHEL7 thanks to https://github.com/GNOME/glib/commit/91113a8aeea40cc2d7dda65b09537980bb602a06#diff-fc9b4bb280a13f8e51c51b434e7d26fd

Version-Release number of selected component (if applicable):

Name        : glib2                        Relocations: (not relocatable)
Version     : 2.28.8                            Vendor: Red Hat, Inc.
Release     : 1.el6                         Build Date: Wed 11 Jun 2014 21:48:27 EST


How reproducible:

Every time

Steps to Reproduce:
1. Run sample program
2. Immediately run: date -s +60sec

Actual results:

Sample program prints "TIMER2 EXPIRE!" less than 60s after it was started

Expected results:

Sample program prints "TIMER2 EXPIRE!" 60s after it was started

Additional info:

#### Sample program

#include <stdio.h>
#include <glib.h>
#include <sys/times.h>
gboolean timer_func(gpointer data){
        printf("TIMER EXPIRE!\n");
        fflush(stdout);
        exit(1);
//      return FALSE;
}
gboolean timer_func2(gpointer data){
        clock_t         ret;
        struct tms buff;

        ret = times(&buff);

        printf("TIMER2 EXPIRE! %d\n", ret);
        fflush(stdout);
        return TRUE;
}
int main(int argc, char** argv){
        GMainLoop *m;
        clock_t         ret;
        struct tms buff;        gint64 t;

//      t = g_get_monotonic_time();
        m = g_main_new(FALSE);
        g_timeout_add(5000, timer_func2, NULL);
        g_timeout_add(60000, timer_func, NULL);
        ret = times(&buff);
        printf("START! %d\n", ret);]
        g_main_run(m);
}

Comment 2 Andrew Beekhof 2014-09-10 06:58:15 UTC
Oops, forgot severity

Comment 3 Jan Kurik 2017-12-06 11:05:40 UTC
Red Hat Enterprise Linux 6 is in the Production 3 Phase. During the Production 3 Phase, Critical impact Security Advisories (RHSAs) and selected Urgent Priority Bug Fix Advisories (RHBAs) may be released as they become available.

The official life cycle policy can be reviewed here:

http://redhat.com/rhel/lifecycle

This issue does not meet the inclusion criteria for the Production 3 Phase and will be marked as CLOSED/WONTFIX. If this remains a critical requirement, please contact Red Hat Customer Support to request a re-evaluation of the issue, citing a clear business justification. Note that a strong business justification will be required for re-evaluation. Red Hat Customer Support can be contacted via the Red Hat Customer Portal at the following URL:

https://access.redhat.com/