|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-03-28 04:04 UTC] galaxy dot mipt at gmail dot com
Description:
------------
In my particular case when the callback for xmlrpc_server_register_method() is a class method attempt to save some of the parameters passed to that callback during xmlrpc_server_call_method() call results in segfault.
Well, I cannot provide short code that would reproduce the segfault I get in my application - it's sort of unstable. But the code below at least show that something is really wrong here.
I believe that $method_name just gets garbage-collected no matter that it is bound with $this->method. Decoupling them, for example like this, helps:
$this->method = (string)$method_name;
Reproduce code:
---------------
class MyXmlRpc {
private $s;
private $method;
function impl($method_name, $params, $user_data){
$this->method = $method_name;
print "Inside impl(): {$this->method}\n";
return array_sum($params);
}
function __construct() {
$this->s = xmlrpc_server_create();
xmlrpc_server_register_method($this->s,'add', array($this, 'impl'));
}
function call($req) {
return xmlrpc_server_call_method($this->s, $req, null);
}
function getMethod() {return $this->method;}
}
$x = new MyXmlRpc;
$resp = $x->call(xmlrpc_encode_request('add',array(1,2,3)));
$method = $x->getMethod();
print "Global scope: $method\n";
Expected result:
----------------
Inside impl(): add
Global scope: add
Actual result:
--------------
Inside impl(): add
Global scope:
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 22:00:01 2025 UTC |
xmlrpc-epi-php.c, line 1115 (xmlrpc_server_call_method): /* cleanup after ourselves. what a sty! */ zval_dtor(data.xmlrpc_method); FREE_ZVAL(data.xmlrpc_method); zval_dtor(data.return_data); FREE_ZVAL(data.return_data); If I get it right data.xmlrpc_method is completely destructed after method call. What if it has more than 1 reference like in reproduce code?