ID: 48346 User updated by: adriano at guiadohardware dot net Reported By: adriano at guiadohardware dot net Status: Bogus Bug Type: Date/time related Operating System: AMD64 Gentoo Hardened, glibc 2.3 PHP Version: 5.2.9 New Comment:
The system has been updated today and rebuild all system twice to ensure that every lib/program was linked against the last available version. Previous Comments: ------------------------------------------------------------------------ [2009-05-20 22:47:44] adriano at guiadohardware dot net * Note the server use the 64 bit AMD64 stable branch of Gentoo. ------------------------------------------------------------------------ [2009-05-20 22:44:56] adriano at guiadohardware dot net This is very strange, because the system IS updated on stable branch of Gentoo. Very stable too, never crashed any common daemon or kernel. Lastest monster hardware server (16 cores, 16gb RAM, etc). Can be related with some security features of Gentoo Hardened Kernel on AMD64, Pax or userland SSP, etc. sys-libs/glibc-2.8_p20080602-r1, sys-devel/gcc-3.4.6-r2, kernel hardened-sources-2.6.28-r7, sys-devel/gcc-3.4.6-r2. I can reproduce this error on another hardware using same Gentoo configs. But I can't reproduce on my workstation Gentoo Hardened (32bits). Anyway, kept the recommendation of manpages is always a good code rules. I don't see any reason to use this useless struct timezone against the documentation too, waste of bytes. Thanks for look it. Regards, Adriano ------------------------------------------------------------------------ [2009-05-20 21:57:47] j...@php.net You really need to update your server. In modern systems I can't reproduce either crash. ------------------------------------------------------------------------ [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