Skip to content

Commit ca08a15

Browse files
committed
warn on stderr when a signal handler is called on a thread not managed by PHP
1 parent d957ddb commit ca08a15

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Zend/zend_execute_API.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,11 @@ ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void) /* {{{ */
13561356
static void zend_timeout_handler(int dummy) /* {{{ */
13571357
{
13581358
#ifdef ZTS
1359-
if (!tsrm_is_managed_thread()) return;
1359+
if (!tsrm_is_managed_thread()) {
1360+
fprintf(stderr, "zend_timeout_handler() called called in a thread not managed by PHP. The expected signal handler will not be called. This is probably a bug.\n");
1361+
1362+
return;
1363+
}
13601364
#else
13611365
if (zend_atomic_bool_load_ex(&EG(timed_out))) {
13621366
/* Die on hard timeout */

Zend/zend_signal.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context)
8787
zend_signal_queue_t *queue, *qtmp;
8888

8989
#ifdef ZTS
90-
if (!tsrm_is_managed_thread()) return;
90+
if (!tsrm_is_managed_thread()) {
91+
fprintf(stderr, "zend_signal_handler_defer() called called in a thread not managed by PHP. The expected signal handler will not be called. This is probably a bug.\n");
92+
93+
return;
94+
}
9195

9296
/* A signal could hit after TSRM shutdown, in this case globals are already freed. */
9397
if (tsrm_is_shutdown()) {

0 commit comments

Comments
 (0)