ID: 48346 Updated by: j...@php.net Reported By: adriano at guiadohardware dot net -Status: Open +Status: Bogus Bug Type: Date/time related Operating System: AMD64 Gentoo Hardened, glibc 2.3 PHP Version: 5.2.9 New Comment:
You really need to update your server. In modern systems I can't reproduce either crash. Previous Comments: ------------------------------------------------------------------------ [2009-05-20 16:11:20] adriano at guiadohardware dot net Description: ------------ Hi, On my server the second argument on gettimeofday raise SEGFAULT. I can't reproduce this error using another system lib version of another server. As manpage of gettimeofday said: "If tzp is not a null pointer, the behavior is unspecified. " (http://linux.die.net/man/3/gettimeofday). This old timezone is no longer used and must be kept outside of kernel. After the patch below this worked. --- php-5.2.9/ext/standard/microtime.c 2009-05-20 12:07:39.000000000 -0300 +++ php-5.2.9/ext/standard/microtime.c 2009-05-20 12:08:33.000000000 -0300 @@ -54,13 +54,12 @@ { zend_bool get_as_float = 0; struct timeval tp = {0}; - struct timezone tz = {0}; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &get_as_float) == FAILURE) { return; } - if (gettimeofday(&tp, &tz)) { + if (gettimeofday(&tp, NULL)) { RETURN_FALSE; } Reproduce code: --------------- crash.php <? print_r(gettimeofday()); ?> gettimeofday.c #include <sys/time.h> #include <time.h> #include <stdlib.h> #include <stdio.h> int main(void) { char buffer[30]; struct timeval tv = {0}; struct timezone tz = {0}; time_t curtime; gettimeofday(&tv, &tz); curtime=tv.tv_sec; strftime(buffer,30,"%m-%d-%Y %T.",localtime(&curtime)); printf("%s%ld\n",buffer,tv.tv_usec); return 0; } Expected result: ---------------- ~ # gcc -Wall -O0 gettimeofday.c -o gettimeofday ~ # ./gettimeofday Segmentation fault ~ # ./crash.php Segmentation fault ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48346&edit=1