Skip to content

Commit 03064b1

Browse files
committed
Make vm_interrupt and timed_out atomic
On Windows these are already set from another thread and should be atomic. On Linux it is unclear to me if this should be done based on the existing code. However, extensions which use vm interrupts are very likely to do the same thing that Windows is doing: set a vm_interrupt from another thread. This combination suggests to me that this change is overdue.
1 parent 9a16533 commit 03064b1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Zend/zend_globals.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#ifndef ZEND_GLOBALS_H
2121
#define ZEND_GLOBALS_H
2222

23-
2423
#include <setjmp.h>
24+
#include <stdatomic.h>
2525

2626
#include "zend_globals_macros.h"
2727

@@ -184,13 +184,17 @@ struct _zend_executor_globals {
184184
uint32_t persistent_classes_count;
185185

186186
HashTable *in_autoload;
187+
188+
/* sizeof atomic_bool is not guaranteed to be the same as sizeof bool,
189+
* but it's somewhat common. The atomic_bools are left by the other
190+
* bools so that the struct packs nicely for such platforms.
191+
*/
192+
atomic_bool vm_interrupt;
193+
atomic_bool timed_out;
187194
bool full_tables_cleanup;
188195

189196
/* for extended information support */
190197
bool no_extensions;
191-
192-
bool vm_interrupt;
193-
bool timed_out;
194198
zend_long hard_timeout;
195199

196200
#ifdef ZEND_WIN32

0 commit comments

Comments
 (0)