Bug #80905 [Com]: VirtualProtect error when proc_open executed in CLI

From: Date: Wed, 19 May 2021 08:02:01 +0000
Subject: Bug #80905 [Com]: VirtualProtect error when proc_open executed in CLI
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233891@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80905&edit=1

 ID:                 80905
 Comment by:         dixyes at gmail dot com
 Reported by:        gajowy at agzeta dot pl
 Summary:            VirtualProtect error when proc_open executed in CLI
 Status:             Open
 Type:               Bug
 Package:            JIT
 Operating System:   Windows 10 64-bit
 PHP Version:        8.0.3
 Block user comment: N
 Private report:     N

 New Comment:

This may fix it, but I donot know if it's proper or why donot do this.

diff --git a/ext/opcache/shared_alloc_win32.c b/ext/opcache/shared_alloc_win32.c
index f7ba4effb3..51b1679867 100644
--- a/ext/opcache/shared_alloc_win32.c
+++ b/ext/opcache/shared_alloc_win32.c
@@ -72,7 +72,7 @@ static void zend_win_error_message(int type, char *msg, int err)
 static char *create_name_with_username(char *name)
 {
        static char newname[MAXPATHLEN + 32 + 4 + 1 + 32 + 21];
-       snprintf(newname, sizeof(newname) - 1, "%s@%.32s@%.20s@%.32s", name,
accel_uname_id, sapi_module.name, zend_system_id);
+       snprintf(newname, sizeof(newname) - 1, "%s@%.32s@%.20s@%.32s@%d", name,
accel_uname_id, sapi_module.name, zend_system_id, GetCurrentProcessId());

        return newname;
 }


Previous Comments:
------------------------------------------------------------------------
[2021-03-25 15:34:29] cmb@php.net

At least as workaround, enforce separate OPcache instances by
using opcache.cache_id[1].  In this case

    $proc=proc_open('php.exe
-dopcache.cache_id=123',[],$pipes,NULL,NULL,['bypass_shell'=>TRUE]);

[1] <https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.cache-id>

------------------------------------------------------------------------
[2021-03-25 09:27:07] gajowy at agzeta dot pl

Description:
------------
When JIT mode is enabled, running child process using proc_open causes crash in CLI mode with
VirtualError message.



Test script:
---------------
1. Set opcache.jit_buffer_size=100M in php.ini
2. Run following script in CLI mode:

$proc=proc_open('php.exe',[],$pipes,NULL,NULL,['bypass_shell'=>TRUE]);
print_r( proc_get_status($proc) );
proc_terminate($proc);

Expected result:
----------------
Array
(
    [command] => php.exe
    [pid] => 13620
    [running] => 1
    [signaled] =>
    [stopped] =>
    [exitcode] => -1
    [termsig] => 0
    [stopsig] => 0
)

Actual result:
--------------
Thu Mar 25 10:20:55 2021 (1612): Fatal Error VirtualProtect() failed


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80905&edit=1


Thread (5 messages)

« previous php.bugs (#233891) next »