File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -3962,15 +3962,24 @@ ZEND_EXT_API void zend_jit_unprotect(void)
3962
3962
{
3963
3963
#ifdef HAVE_MPROTECT
3964
3964
if (!(JIT_G (debug ) & (ZEND_JIT_DEBUG_GDB |ZEND_JIT_DEBUG_PERF_DUMP ))) {
3965
- if (mprotect (dasm_buf , dasm_size , PROT_READ | PROT_WRITE ) != 0 ) {
3965
+ int opts = PROT_READ | PROT_WRITE ;
3966
+ #ifdef ZTS
3967
+ /* Another thread may be executing JITed code. */
3968
+ opts |= PROT_EXEC ;
3969
+ #endif
3970
+ if (mprotect (dasm_buf , dasm_size , opts ) != 0 ) {
3966
3971
fprintf (stderr , "mprotect() failed [%d] %s\n" , errno , strerror (errno ));
3967
3972
}
3968
3973
}
3969
3974
#elif _WIN32
3970
3975
if (!(JIT_G (debug ) & (ZEND_JIT_DEBUG_GDB |ZEND_JIT_DEBUG_PERF_DUMP ))) {
3971
- DWORD old ;
3972
-
3973
- if (!VirtualProtect (dasm_buf , dasm_size , PAGE_READWRITE , & old )) {
3976
+ DWORD old , new ;
3977
+ #ifdef ZTS
3978
+ new = PAGE_EXECUTE_READWRITE ;
3979
+ #else
3980
+ new = PAGE_READWRITE ;
3981
+ #endif
3982
+ if (!VirtualProtect (dasm_buf , dasm_size , new , & old )) {
3974
3983
DWORD err = GetLastError ();
3975
3984
char * msg = php_win32_error_to_msg (err );
3976
3985
fprintf (stderr , "VirtualProtect() failed [%u] %s\n" , err , msg );
You can’t perform that action at this time.
0 commit comments