php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29935 array_filter crashes Apache 2
Submitted: 2004-09-01 20:10 UTC Modified: 2004-09-17 01:00 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: webmaster at martialartsmovies dot net Assigned:
Status: No Feedback Package: Arrays related
PHP Version: 5.0.1 OS: Windows XP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: webmaster at martialartsmovies dot net
New email:
PHP Version: OS:

 

 [2004-09-01 20:10 UTC] webmaster at martialartsmovies dot net
Description:
------------
I have PHP 5.0.1 installed together with the latest stable Apache 2 on Windows XP SP2. I used the example on the array_filter page on php.net an all I got was a window telling me that apache caused a problem and it needed to reboot.

Reproduce code:
---------------
<?php
function odd($var)
{
   return($var % 2 == 1);
}

function even($var)
{
   return($var % 2 == 0);
}

$array1 = array("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);
$array2 = array(6, 7, 8, 9, 10, 11, 12);

echo "Odd :\n";
print_r(array_filter($array1, "odd"));
echo "Even:\n";
print_r(array_filter($array2, "even"));
?> 

Expected result:
----------------
the array_filter function applied to the 2 arrays

Actual result:
--------------
apache 2 crashed.
error.log:
[Wed Sep 01 19:47:14 2004] [notice] Child 2412: Child process is running
[Wed Sep 01 19:47:14 2004] [notice] Child 2412: Acquired the start mutex.
[Wed Sep 01 19:47:14 2004] [notice] Child 2412: Starting 250 worker threads.
[Wed Sep 01 19:50:15 2004] [notice] Parent: child process exited with status 3221225477 -- Restarting.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-02 08:17 UTC] derick@php.net
Please try using this CVS snapshot:

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

Your code works fine for me, please try a snapshot.
 [2004-09-17 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-05-06 17:22 UTC] hans at velum dot net
I am also getting segfaults using array_filter on Apache 2 (on Gentoo Linux).

My backtrace looks like:

#0  0x4070246e in zif_array_filter () from /etc/apache/modules/libphp5.so
#1  0xbfff3f0c in ?? ()
#2  0xbfff3f10 in ?? ()
#3  0xbfff3f14 in ?? ()

I'm not sure what more I can get from that backtrace.

My array filter code looks like:

$discs = array_filter(Bb_DiscussionPeer::doSelectUnreadForUserByClique($cliqueId, $uid), array($this, 'hasPerms'));

Where the first param to array_filter is an array of objects (verified).  And the hasPerms method is a method in parent class that looks like this:

protected function hasPerms($obj) {
  return ($obj->canUser(Perms::READ));
}

(Changing that to be a 'public' method doesn't help.)

I can't seem to narrow down the bug any more than that.  It doesn't seem to happen *all* the time either, but if I have two such similar calls on a page it will segfault.  Sometimes it will segfault if there's only one, but sometimes it works without segfaulting.
 [2005-05-06 17:26 UTC] hans at velum dot net
FYI, I'm using PHP 5.0.4.
 [2005-12-07 02:32 UTC] rob at sharp dot id dot au
I am seeing the same error using version 4.4.1, and was able to remove the error by explicitly allocating arrays using

$variable = Array();
$variable[] = $object;

Instead of allocating data using 

$variable[] = $object;
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 14 08:01:27 2024 UTC