Skip to content

Commit 79853fb

Browse files
committed
Don't crash if work queue function fatals in thread
1 parent 1fbd585 commit 79853fb

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

php_uv.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,7 @@ static int php_uv_do_callback2(zval **retval_ptr, php_uv_t *uv, zval ***params,
12481248
}
12491249

12501250
#ifdef ZTS
1251+
12511252
static int php_uv_do_callback3(zval **retval_ptr, php_uv_t *uv, zval ***params, int param_count, enum php_uv_callback_type type)
12521253
{
12531254
int error = 0;
@@ -1279,9 +1280,17 @@ static int php_uv_do_callback3(zval **retval_ptr, php_uv_t *uv, zval ***params,
12791280
uv->callback[type]->fcc.called_scope = NULL;
12801281
uv->callback[type]->fcc.object_ptr = ZEG->This;
12811282

1282-
if (zend_call_function(&uv->callback[type]->fci, &uv->callback[type]->fcc TSRMLS_CC) != SUCCESS) {
1283+
zend_try {
1284+
if (zend_call_function(&uv->callback[type]->fci, &uv->callback[type]->fcc TSRMLS_CC) != SUCCESS) {
1285+
error = -1;
1286+
}
1287+
1288+
if (retval_ptr != NULL) {
1289+
zval_ptr_dtor(retval_ptr);
1290+
}
1291+
} zend_catch {
12831292
error = -1;
1284-
}
1293+
} zend_end_try();
12851294

12861295
{
12871296
zend_op_array *ops = &uv->callback[type]->fcc.function_handler->op_array;
@@ -1292,9 +1301,6 @@ static int php_uv_do_callback3(zval **retval_ptr, php_uv_t *uv, zval ***params,
12921301
}
12931302
}
12941303
}
1295-
if (retval_ptr != NULL) {
1296-
zval_ptr_dtor(retval_ptr);
1297-
}
12981304

12991305
php_request_shutdown(TSRMLS_C);
13001306
tsrm_set_interpreter_context(old);

0 commit comments

Comments
 (0)