From:             john dot wellesz at firstream dot net
Operating system: w2k/FreeBSD
PHP version:      4.3.7
PHP Bug Type:     Reproducible crash
Bug description:  Stat() function crashes PHP (signal 10) in a particular case

Description:
------------
The bug I'm about to describe exists since at least PHP 4.1.2 and happens
on w2k and freeBSD 4.9 STABLE and probably other platforms (I'm currently
using PHP 4.3.7 and 4.3.4).

My 2 php (w2k and FreeBSD) runs as CGI, the crashes also happens if I
execute my script on command line.

Modules used is probably irrelevant, I use 2 PHP one on FreeBSD and the
other on w2k compiled on totally different way with not the same
modules... (tell me if you cant reproduce the crash, i'll provide more
info)

----------------
BUG REQUIREMENTS:

--> you must be using an error handler
--> Inside your PHP script you must call a stat() function (filemtime,
stat() etc...) over a file that DOESN'T EXIST.
--> In your error handling function*(see note 1) you must either:
   - make another stat() over a file that doesn't exist
   - or call the unlink() function on a file that DOES EXIST

(1): inside your error handling function means:
  - direcly in the error handling function 
  - in a function that is called by your error handling function

RESULT:

Once the content of the error handler has been properly executed PHP
crashes on SIGNAL 10 (BUS ERROR)

NOTE that calling other specific functions than stat() functions family
and unlink() may cause the same issue, I didn't test.



Reproduce code:
---------------
<?php
$dumyfile="foo.txt";
touch($dumyfile);

function userErrorHandler ($errno, $errmsg)
{
    global  $dumyfile;

    unlink($dumyfile); // can be replaced by stat("MUHUHAHAHA"); (same
effect)
    
    echo("<br>\n$errmsg<br>\n");
}

$old_error_handler = set_error_handler("userErrorHandler");

echo "<b>test start</b><br>\n";
stat("nonexistentfileHAHAHA");
echo "<br><b>test end</b>\n";
?>


Expected result:
----------------
---->should prints:

---------
test start

stat(): Stat failed for nonexistentfileHAHAHA (errno=2 - No such file or
directory)

test end
---------

Actual result:
--------------
---->actually prints

---------
test start

stat(): Stat failed for nonexistentfileHAHAHA (errno=2 - No such file or
directory)
---------


Under w2k a litle window appear to say that php.exe has generated errors
etc...

Under FreeBSD I can see in server logs:

pid 33566 (php), uid 27173: exited on signal 10

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

Reply via email to