php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47638 Random fatal error while using callback through array_udiff_assoc
Submitted: 2009-03-12 17:02 UTC Modified: 2009-12-22 01:00 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: luke at cywh dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.2.9 OS: Linux, Mac OS X
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: luke at cywh dot com
New email:
PHP Version: OS:

 

 [2009-03-12 17:02 UTC] luke at cywh dot com
Description:
------------
When making a callback through array_udiff_assoc to a static function 
this fatal error is produced, but randomly:

Fatal error: Non-static method (null)::(null)() cannot be called 
statically in /opt/local/apache2/htdocs/site/cc.php on line 12

This error only occurs about 1/3 of the time or less, and usually 
seems to happen right after saving a file. At first I thought it was 
an eAccelerator issue as I could product this error almost every time 
after re-saving the file (with or without changes), but I was also 
able to reproduce this on my MacBook which I had installed the 5.2 
branch on without any cache engines.

On a stock PHP installation with no extras it is mighty difficult to 
reproduce this error. I was able to make it occur several times if I 
refreshed the page 5-20 times after saving.

In the callback I'm referencing the function as a string: 
"XC::greaterthan". I *think* using array('XC', 'greaterthan') corrects 
the problem, but I am unsure as this error seems to occur completely 
at random, and I have yet to have a 100% solid way of reproducing it.

The code below is the best way I was able to reproduce the occurrence.

Reproduce code:
---------------
class XC {
	static public function greaterthan($value1, $value2) {
		return $value1 > $value2;
	}
}

class test {
	function tester($num1, $num2) {
		var_dump(array_intersect(
			array_keys(
				array_udiff_assoc(array('if' => $num1), array('if' => $num2), 'XC::greaterthan')
			), array('if')
		));
	}
}

$t = new test();

for($i=0; $i<10; $i++) {
	$num1 = mt_rand(1, 100);
	$num2 = mt_rand(1, 100);
	$t->tester($num1, $num2);
}

Expected result:
----------------
No fatal error, just var dumps.

Actual result:
--------------
Fatal error: Non-static method (null)::(null)() cannot be called 
statically in /opt/local/apache2/htdocs/site/cc.php on line 12

(Which points to the array_udiff_assoc function)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-13 01:03 UTC] felipe@php.net
I can't reproduce it.
 [2009-03-13 14:10 UTC] luke at cywh dot com
Is there any way to log what happens when I reproduce it? It's really 
difficult to get it to occur.
 [2009-03-15 12:22 UTC] jani@php.net
Run single Apache child in gdb, then you can backtrace and dump 
variables once this happens. Or run the same in CLI. And I hope 
you're NOT using some threaded MPM with Apache? (I'm guessing you're 
using Apache2 of course since you didn't bother telling that 
either..)
 [2009-03-19 00:34 UTC] luke at cywh dot com
I'm having problems with my MacBook, so I can't get that working on that 
(I had installed a seperate install of Apache 2 and PHP separate from 
the OS, and I get an error regarding libpng with the php5 module, which 
is preventing me from stoping/starting the service).

I was, however, able to produce the same exact error on my development 
machine, but this time I had used array('XC', 'greaterthan') instead of 
'XC::greaterthan'.

This is a live server with a bunch of websites (cpanel install). Is 
there anyway to do this without interring with the rest of the server? 
Perhaps start the apache instance on a different port?

Seems to always happen randomly... has happened twice today during 
development.
 [2009-04-01 13:32 UTC] jani@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.




 [2009-04-09 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".
 [2009-12-15 00:59 UTC] felipe@php.net
Please try using this snapshot:

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

  http://windows.php.net/snapshots/


 [2009-12-22 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: Sat May 18 03:02:51 2024 UTC