Bug 127328 - [PATCH] clock_gettime() acting buggy
[PATCH] clock_gettime() acting buggy
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: glibc (Show other bugs)
3.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-07-06 14:14 EDT by Bernd Schmidt
Modified: 2007-11-30 17:07 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-09-02 01:57:31 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
A patch to fix this problem (1.58 KB, patch)
2004-07-06 14:16 EDT, Bernd Schmidt
no flags Details | Diff

  None (edit)
Description Bernd Schmidt 2004-07-06 14:14:13 EDT
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 14:16:19 EDT
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 07:17:02 EDT
Fix confirmed with glibc-2.3.2-95.26.  Fix will be released in U3 errata.
Comment 3 Jay Turner 2004-09-02 01:57:31 EDT
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

Note You need to log in before you can comment on or make changes to this bug.