php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75675 Uncatchable Fatal error
Submitted: 2017-12-13 11:10 UTC Modified: 2017-12-22 16:52 UTC
From: fabien dot papet at gmail dot com Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 7.1.12 OS: Windows
Private report: No CVE-ID: None
 [2017-12-13 11:10 UTC] fabien dot papet at gmail dot com
Description:
------------
It seems like an uncacthable fatal error is thrown with an exception when an url is unreachable

Test script:
---------------
<?php
echo 'start'.PHP_EOL;

set_error_handler(function() {
    echo 'error'.PHP_EOL;
}, E_ALL);

try {
    $client = new SoapClient('http://thisaddressdoesnotexists', ['exceptions' => true, 'trace' => 0]);
} catch (SoapFault $exception) {
    var_dump('Exception: '.$exception->getMessage());
} catch (Exception $exception) {
    var_dump('Exception: '.$exception->getMessage());
}

echo 'end';


Expected result:
----------------
start
string(143) "Exception: SOAP-ERROR: Parsing WSDL: Couldn't load from 'thisaddressdoesnotexists' : failed to load external entity "thisaddressdoesnotexists"
"
end

Actual result:
--------------
start
error
PHP Fatal error:  SOAP-ERROR: Parsing WSDL: Couldn't load from 'thisaddressdoesnotexists' : failed to load external entity "thisaddressdoesnotexists"
 in C:\Users\.....\soaptest.php on line 9
string(143) "Exception: SOAP-ERROR: Parsing WSDL: Couldn't load from 'thisaddressdoesnotexists' : failed to load external entity "thisaddressdoesnotexists"
"
end


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-13 11:16 UTC] spam2 at rhsoft dot net
this is *not* a general issue - it's the SOAP extension

i reported that more than a year ago - it's hard to understand why this behvaior don't get fixed at all because you can't write any sane code based on SOAP requests where it's naturally that the remote side may not be reachable and you can't handle errors at all the way it works currently

https://bugs.php.net/bug.php?id=73451

[2017-04-08 10:36 UTC] nikic@php.net
Looks like fatal erros in SOAP were for some reason not part of https://wiki.php.net/rfc/throw_error_in_extensions -- probably because SOAP uses non-standard macros to generate them.
 [2017-12-13 11:18 UTC] spam2 at rhsoft dot net
BTW: in PHP7 "catch(Throwable $exception)" is the way to go in PHP7, it catches even parse errors in case of eval and so on
 [2017-12-13 11:26 UTC] nikic@php.net
-Status: Open +Status: Feedback
 [2017-12-13 11:26 UTC] nikic@php.net
Please check if you have XDebug enabled. This code does not reproduce on vanilla PHP.
 [2017-12-20 20:26 UTC] nikic@php.net
Can somebody who has this issue please check whether they have XDebug enabled and whether disabling it fixes the issue?

If this is the case I can backport https://github.com/php/php-src/commit/1dfcd1af9aab9b760d971ceeac18e9e83c85f80f to 7.1, but I'd like to know whether this is the cause of the issue first.
 [2017-12-20 22:05 UTC] fabien dot papet at gmail dot com
-Status: Feedback +Status: Open
 [2017-12-20 22:05 UTC] fabien dot papet at gmail dot com
tested in another computer with php 7.1.11

<?php
echo 'start'.PHP_EOL;

var_dump(extension_loaded('xdebug'));

try {
    $client = new SoapClient('http://thisaddressdoesnotexists', ['exceptions' => true, 'trace' => 0]);
} catch (SoapFault $exception) {
    var_dump('Exception: '.$exception->getMessage());
} catch (Exception $exception) {
    var_dump('Exception: '.$exception->getMessage());
}
echo 'end';



php test.php
start
bool(false)
PHP Fatal error:  SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://thisaddressdoesnotexists' : failed to load external entity "http://thisaddressdoesnotexists"
 in C:\Users\fabie\Desktop\test.php on line 7
string(157) "Exception: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://thisaddressdoesnotexists' : failed to load external entity "http://thisaddressdoesnotexists"
"
end
 [2017-12-20 22:37 UTC] nikic@php.net
Thanks for checking!

I misread your initial output -- I thought execution aborts after the error, while what happens is that the exception is caught, but the error is also printed. The reason why it's printed for you (but was not for me) is probably that you have log_errors=1 set. I can now reproduce the same result.

I will backport the previously mentioned commit to 7.1 and 7.2. This will remove the fatal error, but calls to the error handler for warnings may remain.
 [2017-12-22 16:52 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2017-12-22 16:52 UTC] nikic@php.net
Applied https://github.com/php/php-src/commit/024637378827ff03ccfb6b903c9d9b968d30af8d to 7.1+, so this should be resolved now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 07:01:29 2024 UTC