php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32422 Access Violation on calling PEAR Date::before
Submitted: 2005-03-23 04:07 UTC Modified: 2006-06-26 10:38 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: rob at wildlime dot com Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 4.3.10 OS: Windows XP SP2
Private report: No CVE-ID: None
 [2005-03-23 04:07 UTC] rob at wildlime dot com
Description:
------------
Experiencing an intermittent (once every 5-10 requests) access violation.

btw, I have posted this to the PHP bug list rather than the PEAR one as it is a crash, not just a script error.

Here's the info I can glean from the debugger.  I'm afraid I don't have the debug builds.

Windows XP pro SP2
Apache/1.3.33 (Win32)
PHP/4.3.10

stack trace:
7C910C27 C:\WINDOWS\system32\ntdll.dll
7C910D5C C:\WINDOWS\system32\ntdll.dll
77C2C2DE C:\WINDOWS\system32\msvcrt.dll
77C39AE9 C:\WINDOWS\system32\msvcrt.dll
77C35F5D C:\WINDOWS\system32\msvcrt.dll
77C35FEC C:\WINDOWS\system32\msvcrt.dll
10047D4E c:\php4\php4ts.dll

or sometimes:
77C46137 C:\WINDOWS\system32\msvcrt.dll
100CA6AE c:\php4\php4ts.dll
60002E50 c:\php4\php4apache.dll
6000186F c:\php4\php4apache.dll

dll base addresses:
0x60000000 php4apache.dll
0x10000000 php4ts.dll

Reproduce code:
---------------
<?php

require_once 'Date.php';

$now =& new Date();

$year = 2005;
$month = 3;
$day = 24;
$time = '09:00';
$s = sprintf("%04d-%02d-%02dT%s:00", $year, $month, $day, $time);		
$date = new Date($s);

$date->before($now);
?>

Expected result:
----------------
nothing - no output, so blank browser window

Actual result:
--------------
Access violation every 5-10 requests. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-29 02:05 UTC] rob at wildlime dot com
Installed php 4.3.11 RC1 (windows) to c:\php, but PEAR wont't install.  The error on running go-pear.bat, accepting the defaults, is: "failed to write c:\php\pear\data\PEAR\.tmppackage.dtd" 

There is plenty of disk space and I'm using an admin account.
 [2005-03-29 07:53 UTC] rob at wildlime dot com
Here's another stack trace, using the MS debugger to get access to the symbol names

ntdll!RtlpCoalesceFreeBlocks+0x21
ntdll!RtlFreeHeap+0x2e9
msvcrt!free+0xc3
msvcrt!__crtsetenv+0x193
msvcrt!_putenv_lk+0x42
msvcrt!_putenv+0x20
WARNING: Stack unwind information not available. Following frames may be wrong.
php4ts!php_get_inf+0xf6e

Error details from the debugger:
(268.ddc): Access violation - code c0000005 (!!! second chance !!!)
eax=00000418 ebx=00830000 ecx=7ffda000 edx=00830608 esi=0082fd68 edi=00830180
eip=7c910c27 esp=0108d978 ebp=0108d984 iopl=0         nv up ei ng nz na po cy
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000287
ntdll!RtlpCoalesceFreeBlocks+0x21:
7c910c27 f6460501         test    byte ptr [esi+0x5],0x1  ds:0023:0082fd6d=??

(NB still using php 4.3.10)
 [2005-03-29 10:27 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

..and provide the trace when using the snapshot.


 [2005-03-30 01:49 UTC] rob at wildlime dot com
Using PHP/4.3.11RC2-dev

(btw, is it intentional that pear installs to c:\php\pear\pear?)

Same result - frequent access violation.

stack trace:
ntdll!RtlpCoalesceFreeBlocks+0x21
ntdll!RtlFreeHeap+0x2e9
msvcrt!free+0xc3
msvcrt!__crtsetenv+0x193
msvcrt!_putenv_lk+0x42
msvcrt!_putenv+0x20
WARNING: Stack unwind information not available. Following frames may be wrong.
php4ts!php_get_inf+0xfae
 [2005-03-30 08:54 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

(yes, it's PHP5, but I'd like to know if this happens with it too..)
 [2005-03-31 01:30 UTC] rob at wildlime dot com
Using PHP/5.1.0-dev

access violation immediately on starting Apache

stack trace:
php5ts!zend_do_inherit_interfaces+0x14e

(yes, that's all)

I haven't installed PEAR yet...
 [2005-03-31 01:41 UTC] rob at wildlime dot com
The access violation on starting Apache goes away if I disable all the extensions I was previously using (mysql, curl, openssl)

I have tested this using php.ini-recommended, the only change being setting the extension dir from ./ to c:\php\ext
 [2005-03-31 08:16 UTC] sniper@php.net
Using extensions from different PHP version will not work of course.. but does the PEAR crap work any better?

 [2005-04-06 04:21 UTC] rob at wildlime dot com
sorry for the delay...

using PHP/5.1.0-dev
 - no extensions loaded
 - PEAR installed (default packages and Date)

Got the same access violation.

stack trace:
ntdll!RtlpCoalesceFreeBlocks+0x21
ntdll!RtlFreeHeap+0x2e9
msvcrt!free+0xc3
msvcrt!__crtsetenv+0x193
msvcrt!_putenv_lk+0x42
msvcrt!_putenv+0x20
WARNING: Stack unwind information not available. Following frames may be wrong.
php5ts!php_get_inf+0x1083
 [2005-04-06 04:23 UTC] rob at wildlime dot com
btw, the extensions loaded before were the ones packaged with PHP5, not old 4.3.10 ones!
 [2005-04-06 05:52 UTC] rob at wildlime dot com
Looks like this bug has been encountered before:
http://pear.php.net/bugs/bug.php?id=2344

.. but the Date package owners maintain that it's not their problem.

(Dunno how I didn't find that earlier :-/  I did search the bug DBs before posting, honest!)
 [2005-04-08 00:27 UTC] sniper@php.net
Pierre promised to look into this..(or rather bogus this with good explanation..)

 [2005-04-08 01:23 UTC] rob at wildlime dot com
Any chance of PHP catching the exception in putenv/gettenv and chucking a more informative error?  Would help anyone else who hits this problem.
 [2005-04-29 13:04 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

Is it still reproducible ?
If yes, is it reproducible on NON-win32 systems ?
 [2005-05-07 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".
 [2005-10-25 16:06 UTC] hannu at lohtader dot com
I am currently tracing bug that is somehow related to sprintf with %d parameters.

first it occured with dotproject project-environment, on line looking like this (PEAR date package, format method):
$output .= sprintf("%02d",$this->month);

Again with phpmyadmin, file defines.lib.php line 47:
define('PMA_PHP_INT_VERSION', (int)sprintf('%d%02d%02d', $match[1], $match[2], $match[3]));

I can not reproduce this just by creating new script, creating match array and running that define - everything works just FINE!
Server is:
php version 4.4.0
Linux hostname 2.4.7-10 #1 Thu Sep 6 16:46:36 EDT 2001 i686 

I was able to bypass this by installing dotproject to another server with php 4.3.5 / Linux hostname 2.4.27-grs-smp #1 SMP Thu Sep 16 22:12:09 EEST 2004 i686 

WHAT IS IMPORTANT is that I copy pasted from your code lines:
$year = 2005;
$month = 3;
$day = 24;
$time = '09:00';
$s = sprintf("%04d-%02d-%02dT%s:00", $year, $month, $day, $time);
to file defines.lib.php before line 47 and these lines from your code made system just silently die in a same way that lines I have presented. I have debugged this by using exit before and after these problem lines.

So your lines made the same error I am tracing. Error is that nothing is returned to the browser. Script just silently dies on calling sprintf. So we are getting at least some hint that your error is also sprintf -related!

I am totally confused what causes this. I do not know if this is php bug, but wanted to comment it here to make some more glues to anyone having this problem.
 [2006-06-26 10:38 UTC] pajoye@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Setting ENV is not thread safe. No idea was this bug was kept so long open/waiting for feedback. Also I cannot do anything against that :)

 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Mar 29 10:01:24 2020 UTC