php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59143 Segmenation Fault When Called via call_user_func_array
Submitted: 2010-04-01 11:16 UTC Modified: 2010-04-28 11:00 UTC
From: james at stuart dot name Assigned: iekpo (profile)
Status: Not a bug Package: solr (PECL)
PHP Version: 5.2.11 OS: Unix
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
50 + 11 = ?
Subscribe to this entry?

 
 [2010-04-01 11:16 UTC] james at stuart dot name
Description:
------------
SolrQuery methods cannot be called via call_user_func_array.  The result of attempting to do so is a segmentation fault.

I've had this problem on the following platforms:
FreeBSD 7.x using PHP 5.2.11 and Solr 0.9.9
Ubuntu 9.04 using PHP 5.2.6 and Solr 0.9.9

The Solr extension on both systems was installed manually (download source, unpack, phpize, configure, make, make install) to go around the curl detection problem (bug 17012).  All of the components of the extension that we have tested seem to work correctly in both places when called normally.

PHP.ini has not been modified beyond the inclusion of the extension.

The backtrace of the core dump caused by the script below is:
#0  0x00000000005295a6 in zend_objects_store_del_ref_by_handle ()
#1  0x000000000052977f in zend_objects_store_del_ref ()
#2  0x00000000004fd8b6 in _zval_ptr_dtor ()
#3  0x00000000005154a3 in zend_hash_destroy ()
#4  0x0000000000509fdf in _zval_dtor_func ()
#5  0x00000000004fd8b6 in _zval_ptr_dtor ()
#6  0x000000000052b4f3 in zend_do_fcall_common_helper_SPEC ()
#7  0x000000000052aca3 in execute ()
#8  0x000000000050a2e3 in zend_execute_scripts ()
#9  0x00000000004c5bad in php_execute_script ()
#10 0x0000000000590d32 in main ()

Based on that I'm not sure if this is a PHP problem or a Solr problem.  I have not had a problem like this anywhere else and calling functions via call_user_func_array works fine for SolrClient so my assumption is that it is specific to the SolrQuery portion of the extension.

Any suggestions?

Thanks!
James

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

$solr = new SolrQuery();

// Works
$solr->setQuery('*:*');
echo $solr->getQuery() . PHP_EOL; // *:*

// Does not work
call_user_func_array(array($solr, 'setQuery'), array('*:*');
// Segfaults above
echo $solr->getQuery(); // *:*

Expected result:
----------------
*:*
*:*

Actual result:
--------------
*:*
Segmentation fault: 11 (core dumped)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-03 06:58 UTC] iekpo@php.net
This looks like it could be a php specific issue.

I used your reproduce code and I was able to get the expected result on php 5.3.0 and php 5.3.1

I know there could be differences with how the call_user_func_array function works in php 5.2 and php 5.3

I will do more investigation when I get a chance.
 [2010-04-23 23:19 UTC] iekpo@php.net
I was not able to reproduce your observation.

The parameters are being passed by reference  whereas, it is expecting it to be passed by value.

This could be another reason for the error.
 [2010-04-27 22:37 UTC] iekpo@php.net
I have tried to reproduce the error but I am unable to do so.
 [2010-04-28 10:17 UTC] james at stuart dot name
What platform were you able to get this to work on?  I can 
give this a shot again to make sure its not something I'm 
doing wrong.
 [2010-04-28 10:24 UTC] iekpo@php.net
Hi,

I attempted to reproduce it on Ubuntu 8.02.4 running PHP 5.3.0 with Solr 0.9.9
 [2010-04-28 10:59 UTC] iekpo@php.net
I was able to reproduce this in PHP 5.2.13

There is definitely a difference between the 2 php versions.

You can see this by reading the notes here

http://php.net/manual/en/function.call-user-func-array.php

Others have experienced similar observations as well.

Here is the workaround

<?php

$solr = new SolrQuery();

// Works
$solr->setQuery('*:*');
echo $solr->getQuery() . PHP_EOL; // *:*


// This is the workaround for PHP < 5.3.0

$string = "*:*";

$param = array($solr, $string);

function callquery($solr, $query)
{
    $solr->setQuery($query);
}

call_user_func_array('callquery', $param);

echo $solr->getQuery(); // *:*

I am going to close the ticket.

This is not an issue with the extension but due to difference with which the call_user_func_array works in 5.2 or earlier
 [2010-04-28 11:00 UTC] iekpo@php.net
I am going to close the ticket.

This is not an issue with the extension but due to differences with which the call_user_func_array works in 5.2 or earlier.

It works difference in PHP 5.3.0 and later
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 16:01:29 2024 UTC