Bug 127328

Summary: [PATCH] clock_gettime() acting buggy
Product: Red Hat Enterprise Linux 3 Reporter: Bernd Schmidt <bernds>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: tao
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-09-02 05:57:31 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
A patch to fix this problem none

Description Bernd Schmidt 2004-07-06 18:14:13 UTC
From Issue Tracker (38501):
It looks like we are hitting a bug in the pthreads implementation in
LinuxThreads-0.10 version in AS 3.0. Specifically, the clock_gettime()
function with CLOCK_THREAD_CPUTIME_ID is buggy and coredumps. A
workaround is to use CLOCK_PROCESS_CPUTIME_ID which works.

bernds@tesuji:~> cat timer-test.c
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#define MY_CLOCK_ID CLOCK_THREAD_CPUTIME_ID
/*
#define MY_CLOCK_ID CLOCK_PROCESS_CPUTIME_ID
*/
typedef struct timespec timespec_t;
int main(int argc, char **argv)
{
        timespec_t start;
        char dummy1[100];
        timespec_t stop;
        char dummy2[100];
        printf("Starting Timer...\n");
        clock_gettime(MY_CLOCK_ID, &start);
        printf("Sleeping...\n");
        sleep(1);
        printf("Stopping Timer...\n");
        clock_gettime(MY_CLOCK_ID, &stop);
        printf("Done...\n");
}
bernds@tesuji:~> gcc timer-test.c -lrt
bernds@tesuji:~>  LD_ASSUME_KERNEL=2.2.5 ./a.out
Starting Timer...
Segmentation fault

Comment 1 Bernd Schmidt 2004-07-06 18:16:19 UTC
Created attachment 101663 [details]
A patch to fix this problem

The problem is obvious once you spot it - function type mismatch between
linuxthreads and sysdeps/unix/clock_settime.c

Comment 2 Jay Turner 2004-08-20 11:17:02 UTC
Fix confirmed with glibc-2.3.2-95.26.  Fix will be released in U3 errata.

Comment 3 Jay Turner 2004-09-02 05:57:31 UTC
An errata has been issued which should help the problem 
described in this bug report. This report is therefore being 
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files, 
please follow the link below. You may reopen this bug report 
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2004-384.html