php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28344 Memory/Stack or mktime() problem
Submitted: 2004-05-10 09:19 UTC Modified: 2004-07-19 01:00 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: powerstat at web dot de Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 4.3.6 OS: RedHat AS 2.1 IA64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: powerstat at web dot de
New email:
PHP Version: OS:

 

 [2004-05-10 09:19 UTC] powerstat at web dot de
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:



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-19 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 19:01:30 2024 UTC