Skip to content

Commit 637d867

Browse files
committed
Fix ZTS issue regarding new Windows CTRL handling API
php_win32_signal_system_ctrl_handler() is called from a kernel thread, so the former initialization of `vm_interrupt_flag` has no effect, since it is defined as thread-local. This is, however, not necessary, since the CTRL signal handling is supposed to work only for the main thread anyway. We therefore change `vm_interrupt_flag` and the related variables to true globals. This also allows us to unmark the respective test case as XFAIL. Furthermore, `vm_interrupt_flag` is declared as `zend_bool *`, so we better treat it such.
1 parent d669d55 commit 637d867

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

sapi/cli/tests/sapi_windows_set_ctrl_handler.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ include "skipinf.inc";
88
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
99
die("skip this test is for Windows platforms only");
1010
?>
11-
--XFAIL--
12-
Fails on AppVeyor
1311
--FILE--
1412
<?php
1513

win32/signal.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121

2222
#include "win32/console.h"
2323

24-
ZEND_TLS zval ctrl_handler;
25-
ZEND_TLS DWORD ctrl_evt = (DWORD)-1;
26-
ZEND_TLS zend_bool *vm_interrupt_flag = NULL;
24+
/* true globals; only used from main thread and from kernel callback */
25+
static zval ctrl_handler;
26+
static DWORD ctrl_evt = (DWORD)-1;
27+
static zend_bool *vm_interrupt_flag = NULL;
2728

2829
static void (*orig_interrupt_function)(zend_execute_data *execute_data);
2930

@@ -78,7 +79,7 @@ static BOOL WINAPI php_win32_signal_system_ctrl_handler(DWORD evt)
7879
return FALSE;
7980
}
8081

81-
(void)InterlockedExchange((LONG*)vm_interrupt_flag, 1);
82+
(void)InterlockedExchange8(vm_interrupt_flag, 1);
8283

8384
ctrl_evt = evt;
8485

0 commit comments

Comments
 (0)