Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 126385

Summary: times(NULL) function returns negative value
Product: Gentoo Linux Reporter: Christophe Boccheciampe <cb>
Component: [OLD] LibraryAssignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers <kernel>
Status: RESOLVED INVALID    
Severity: major CC: vapier
Priority: High    
Version: 2006.0   
Hardware: x86   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Christophe Boccheciampe 2006-03-15 22:51:17 UTC
This simple program should return a positive value

-----------------------
#include <sys/times.h>
#include <iostream>

main() {
        std::cout << times(NULL) << std::endl;
}
-----------------------

Instead I get something like "-2142386810" as a result.

These values freeze some applications like Oracle-10.2.0.

Some details :
Portage 2.0.54 (default-linux/x86/2005.1, gcc-3.3.6, glibc-2.3.5-r2, 2.6.14.3 i686)
=================================================================
System uname: 2.6.14.3 i686 AMD Opteron(tm) Processor 852
Gentoo Base System version 1.6.14

- 4 CPU (AMD Opteron 852 - 2.6GHz)
- 16 GB RAM
- Uptime : about 50 days
- all updates done
- no masked packages installed

I had to reboot very quickly since it is our main students server. times(NULL) now returns a positive value (until ... ?).

Tell me if more details needed.
Comment 1 SpanKY gentoo-dev 2006-03-16 17:41:09 UTC
glibc doesnt implement times() ... it merely calls the kernel
Comment 2 SpanKY gentoo-dev 2006-03-16 17:44:52 UTC
but really i dont see this as a bug

if we review the specs on the function:
http://www.opengroup.org/onlinepubs/009695399/functions/times.html

the return value has these characteristics:
 - completely arbitrary
 - success can be any value at all except for -1
 - return value may be overflowed as long as the result isnt -1