php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37850 Reference counting bug in SoapClient::__setSoapHeaders()
Submitted: 2006-06-19 17:46 UTC Modified: 2006-07-13 01:00 UTC
From: jeremiahh at allstardirectories dot com Assigned:
Status: No Feedback Package: SOAP related
PHP Version: 5.1.4 OS: Linux
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: jeremiahh at allstardirectories dot com
New email:
PHP Version: OS:

 

 [2006-06-19 17:46 UTC] jeremiahh at allstardirectories dot com
Description:
------------
The undocumented method SoapClient::__setSoapHeaders() incorrectly handles reference counting when a single SoapHeader object is passed.

Reproduce code:
---------------
function someMethod()
{
  $headers = new SoapHeader(...);
  $client = new SoapClient(...);
  $client->__setSoapHeaders($headers);

  $this->saved_client = $client;
}

function someOtherMethod()
{
  $client = $this->saved_client;
  $client->__soapCall(...);
}

Expected result:
----------------
For the code

$obj->someMethod();
$obj->someOtherMethod();

you would expect the call $client->__soapCall() to succeed with the appropriate soap headers.

Actual result:
--------------
It crashes.  If one does a print_r($this->saved_client) in both methods the problem is obvious.  The reference count for $headers is not incremented in __setSoapHeaders() and so when  someMethod() finished the object is destroyed while the SoapClient object is still referencing it.  Then in someOtherMethod() the SoapHeader object is no longer available.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-19 18:00 UTC] jeremiahh at allstardirectories dot com
It is important to note that this bug only seems to happen in the case where a single SoapHeader object is passed to __setSoapHeaders().  If you pass an array of SoapHeaders, such as array(soapHeaderObj) then the problem is non-existent.  When you pass it in an array the reference counting happens automatically by the array constructor.

Also, this problem does not exist in the SoapHeader()::__call method which correctly adds a reference when a single SoapHeader object is passed:

ZVAL_ADDREF(headers);
 [2006-06-19 18:03 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.


 [2006-06-27 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".
 [2006-07-03 18:25 UTC] jeremiahh at allstardirectories dot com
I'm not sure what more you need to reproduce it.  The code I gave should be enough to reproduce the problem.  For obvious reasons I can not fill in the arguments to the methods since they are user specific.  What exactly are you looking for?
 [2006-07-05 09:05 UTC] tony2001@php.net
I am looking for a short but complete reproduce script, which I could copy/paste and reproduce the problem.
 [2006-07-13 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".
 [2007-01-29 09:19 UTC] reshma_rajagopal at yahoo dot com
__setSoapHeaders does not have any documentation and does this work for PHP 5.0.4?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 11 05:01:27 2024 UTC