Skip to content

Commit ff3b4ec

Browse files
dktappscmb69
authored andcommitted
Fix GH-16851: JIT_G(enabled) not set correctly on other threads
There doesn't seem to be a thread post-startup hook that runs after zend_startup_cb() that could be used for this this fix is similar to accel_startup_ok() as seen here: https://github.com/php/php-src/blob/fc1db70f106525e81f9a24539340b7cf2e82e844/ext/opcache/ZendAccelerator.c#L2631-L2634 Closes GH-16853.
1 parent 3656a84 commit ff3b4ec

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ PHP NEWS
2727
- Opcache:
2828
. Fixed bug GH-16770 (Tracing JIT type mismatch when returning UNDEF).
2929
(nielsdos, Dmitry)
30+
. Fixed bug GH-16851 (JIT_G(enabled) not set correctly on other threads).
31+
(dktapps)
3032

3133
- OpenSSL:
3234
. Prevent unexpected array entry conversion when reading key. (nielsdos)

ext/opcache/ZendAccelerator.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3283,6 +3283,8 @@ static zend_result accel_post_startup(void)
32833283
if (JIT_G(buffer_size) != 0) {
32843284
zend_accel_error(ACCEL_LOG_WARNING, "Could not enable JIT!");
32853285
}
3286+
} else {
3287+
zend_jit_startup_ok = true;
32863288
}
32873289
}
32883290
#endif

ext/opcache/jit/zend_jit.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ typedef struct _zend_jit_stub {
103103
#define JIT_STUB(name, offset, adjustment) \
104104
{JIT_STUB_PREFIX #name, zend_jit_ ## name ## _stub, offset, adjustment}
105105

106+
bool zend_jit_startup_ok = false;
107+
106108
zend_ulong zend_jit_profile_counter = 0;
107109
int zend_jit_profile_counter_rid = -1;
108110

@@ -5096,6 +5098,13 @@ static void zend_jit_reset_counters(void)
50965098

50975099
ZEND_EXT_API void zend_jit_activate(void)
50985100
{
5101+
#ifdef ZTS
5102+
if (!zend_jit_startup_ok) {
5103+
JIT_G(enabled) = 0;
5104+
JIT_G(on) = 0;
5105+
return;
5106+
}
5107+
#endif
50995108
zend_jit_profile_counter = 0;
51005109
if (JIT_G(on)) {
51015110
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_COUNTERS) {

ext/opcache/jit/zend_jit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ typedef struct _zend_jit_trace_rec zend_jit_trace_rec;
9191
typedef struct _zend_jit_trace_stack_frame zend_jit_trace_stack_frame;
9292
typedef struct _sym_node zend_sym_node;
9393

94+
extern bool zend_jit_startup_ok;
95+
9496
typedef struct _zend_jit_globals {
9597
bool enabled;
9698
bool on;

0 commit comments

Comments
 (0)