From:             powerstat at web dot de
Operating system: RedHat AS 2.1 IA64 
PHP version:      4.3.6
PHP Bug Type:     Unknown/Other Function
Bug description:  Memory/Stack or mktime() problem

Description:
------------
PHP has a function called mktime()
(see http://www.php.net/manual/en/function.mktime.php)
this uses internally the Unix/Linux mktime() function.

We detected the problem within the phpGroupWare
(actual cvs checkout from branch 0.9.16)

www.phpgroupware.org 
cvs repositories:
https://savannah.gnu.org/projects/phpgwapi
and
https://savannah.gnu.org/projects/phpgroupware/
 

The bug itself will occur in the following file: 
http://savannah.gnu.org/cgi-bin/viewcvs/phpgwapi/phpgwapi/inc/class.datetime.inc.php?rev=1.5.2.12.2.8&content-type=text/vnd.viewcvs-markup

in the method 

function get_weekday_start($year,$month,$day)

when php mktime() will be called, the result (in seconds) will be off by 2
days. This happens especially when zero or negative day values will be
used.
These values are allowed by php mktime() as well as by the underlying unix
mktime()
(see Itanium man mktime).

We found that the problem only occurs in the above file,
using the same values in a small test script will give backe the correct
results!

We assume that it might be a memory/stack problem within php itself, that
we are not able to track down.


Reproduce code:
---------------
For URLs see description.

switch($weekday)
{
  case 0:
    $sday = mktime(2,0,0,$month,$day - 6,$year);
    break;
  case 1:
    $sday = mktime(2,0,0,$month,$day,$year);
    break;
  default:
    $sday = mktime(2,0,0,$month,$day - ($weekday - 1),$year);
    echo ':' . $day . ':' . $weekday . "<br />\n";
    echo ':' . $year . '/' . $month . '/' . ($day - ($weekday - 1)) . ' :
' . $sday . ":<br /><hr />\n";
}


Expected result:
----------------
The correct value in seconds (differs a bit by tomezone settings), but not
values that are 2 days or more off.

orrect Output values here 32bit linux machine:
 
:1:4
:2004/4/-2 : 1080518400:
:1:2
:2004/6/0 : 1085961600:
:1:6
:2004/05/-4 : 1082937600:
:1:6
:2004/05/-4 : 1082937600:


wrong output values 64 bit itanium2:
 
:1:4
:2004/4/-2 : 1080694800:
:1:2
:2004/6/0 : 1085965200:
:1:6
:2004/05/-4 : 1083286800:
:1:6
:2004/05/-4 : 1083286800:



-- 
Edit bug report at http://bugs.php.net/?id=28344&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28344&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28344&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28344&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28344&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28344&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28344&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28344&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28344&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28344&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28344&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28344&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28344&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28344&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28344&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28344&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28344&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28344&r=float

Reply via email to