Skip to content

Commit

Permalink
clear backtrace when throwing an exception
Browse files Browse the repository at this point in the history
Without this, the ext/soap tests would trigger a double stack trace:

```
  Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from '/Users/enorris/workspace/php-src/ex\
t/soap/tests/bugs/bug62900.xsd', unexpected 'targetNamespace'='http://www.w3.org/XML/1998/namespacex', expected 'http://www.w3.org/XML/1998\
/namespace' in /Users/enorris/workspace/php-src/ext/soap/tests/bugs/bug62900_run:2
  #0 /Users/enorris/workspace/php-src/ext/soap/tests/bugs/bug62900_run(2): SoapClient->__construct('/Users/enorris/...')
  #1 {main}
    thrown in /Users/enorris/workspace/php-src/ext/soap/tests/bugs/bug62900_run on line 2
  Stack trace:
  #0 /Users/enorris/workspace/php-src/ext/soap/tests/bugs/bug62900_run(2): SoapClient->__construct('/Users/enorris/...')
  #1 {main}
```
  • Loading branch information
ericnorris committed Jan 8, 2025
1 parent a44ac31 commit e843e06
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,10 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit
ZVAL_OBJ(&exception, ex);
ce_exception = ex->ce;
EG(exception) = NULL;

zval_ptr_dtor(&EG(error_backtrace));
ZVAL_UNDEF(&EG(error_backtrace));

if (ce_exception == zend_ce_parse_error || ce_exception == zend_ce_compile_error) {
zend_string *message = zval_get_string(GET_PROPERTY(&exception, ZEND_STR_MESSAGE));
zend_string *file = zval_get_string(GET_PROPERTY_SILENT(&exception, ZEND_STR_FILE));
Expand Down

0 comments on commit e843e06

Please sign in to comment.