]> granicus.if.org Git - php/commitdiff
Revert "Merge branch 'PHP-7.3' into PHP-7.4"
authorChristoph M. Becker <cmbecker69@gmx.de>
Wed, 29 Jul 2020 11:32:59 +0000 (13:32 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Wed, 29 Jul 2020 11:32:59 +0000 (13:32 +0200)
This reverts commit e1f6ab3388f509782857557ee1e40a66b2bb6455, reversing
changes made to e0ebe56ebfc80bae3875b23eca4cbe0803f41e79.

There are obviously issues with running tests in parallel, maybe
related to the cache ID.  This needs to be investigated.  Revert for
now.

NEWS
ext/opcache/shared_alloc_win32.c

diff --git a/NEWS b/NEWS
index b8dd6b2cced9089dbadb8929a5a80846483d0dfa..a4b473cbd2570dceacad4b90b6383669798e6301 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,10 +12,6 @@ PHP                                                                        NEWS
 - LDAP:
   . Fixed memory leaks. (ptomulik)
 
-- OPcache:
-  . Fixed bug #73060 (php failed with error after temp folder cleaned up).
-    (cmb)
-
 06 Aug 2020, PHP 7.4.9
 
 - Apache:
index 0105fbb2df3644351156c8e9c97730f99c6d1e77..d2c31dd63b04a7b262b62e26854341a53961c1e0 100644 (file)
 
 #define ACCEL_FILEMAP_NAME "ZendOPcache.SharedMemoryArea"
 #define ACCEL_MUTEX_NAME "ZendOPcache.SharedMemoryMutex"
+#define ACCEL_FILEMAP_BASE_DEFAULT 0x01000000
+#define ACCEL_FILEMAP_BASE "ZendOPcache.MemoryBase"
 #define ACCEL_EVENT_SOURCE "Zend OPcache"
 
-/* address of mapping base and address of execute_ex */
-#define ACCEL_BASE_POINTER_SIZE (2 * sizeof(void*))
-
 static HANDLE memfile = NULL, memory_mutex = NULL;
 static void *mapping_base;
 
@@ -76,6 +75,22 @@ static char *create_name_with_username(char *name)
        return newname;
 }
 
+static char *get_mmap_base_file(void)
+{
+       static char windir[MAXPATHLEN+ 32 + 3 + sizeof("\\\\@") + 1 + 32 + 21];
+       int l;
+
+       GetTempPath(MAXPATHLEN, windir);
+       l = strlen(windir);
+       if ('\\' == windir[l-1]) {
+               l--;
+       }
+
+       snprintf(windir + l, sizeof(windir) - l - 1, "\\%s@%.32s@%.20s@%.32s", ACCEL_FILEMAP_BASE, accel_uname_id, sapi_module.name, accel_system_id);
+
+       return windir;
+}
+
 void zend_shared_alloc_create_lock(void)
 {
        memory_mutex = CreateMutex(NULL, FALSE, create_name_with_username(ACCEL_MUTEX_NAME));
@@ -104,20 +119,39 @@ static int zend_shared_alloc_reattach(size_t requested_size, char **error_in)
 {
        int err;
        void *wanted_mapping_base;
+       char *mmap_base_file = get_mmap_base_file();
+       FILE *fp = fopen(mmap_base_file, "r");
        MEMORY_BASIC_INFORMATION info;
        void *execute_ex_base;
        int execute_ex_moved;
 
-       mapping_base = MapViewOfFileEx(memfile, FILE_MAP_ALL_ACCESS, 0, 0, ACCEL_BASE_POINTER_SIZE, NULL);
-       if (mapping_base == NULL) {
+       if (!fp) {
+               err = GetLastError();
+               zend_win_error_message(ACCEL_LOG_WARNING, mmap_base_file, err);
+               zend_win_error_message(ACCEL_LOG_FATAL, "Unable to open base address file", err);
+               *error_in="fopen";
+               return ALLOC_FAILURE;
+       }
+       if (!fscanf(fp, "%p", &wanted_mapping_base)) {
                err = GetLastError();
                zend_win_error_message(ACCEL_LOG_FATAL, "Unable to read base address", err);
                *error_in="read mapping base";
+               fclose(fp);
+               return ALLOC_FAILURE;
+       }
+       if (!fscanf(fp, "%p", &execute_ex_base)) {
+               err = GetLastError();
+               zend_win_error_message(ACCEL_LOG_FATAL, "Unable to read execute_ex base address", err);
+               *error_in="read execute_ex base";
+               fclose(fp);
                return ALLOC_FAILURE;
        }
-       wanted_mapping_base = ((void**)mapping_base)[0];
-       execute_ex_base = ((void**)mapping_base)[1];
-       UnmapViewOfFile(mapping_base);
+       fclose(fp);
+
+       if (0 > win32_utime(mmap_base_file, NULL)) {
+               err = GetLastError();
+               zend_win_error_message(ACCEL_LOG_WARNING, mmap_base_file, err);
+       }
 
        execute_ex_moved = (void *)execute_ex != execute_ex_base;
 
@@ -173,7 +207,7 @@ static int zend_shared_alloc_reattach(size_t requested_size, char **error_in)
                }
                return ALLOC_FAIL_MAPPING;
        }
-       smm_shared_globals = (zend_smm_shared_globals *) ((char*)mapping_base + ACCEL_BASE_POINTER_SIZE);
+       smm_shared_globals = (zend_smm_shared_globals *) mapping_base;
 
        return SUCCESSFULLY_REATTACHED;
 }
@@ -291,9 +325,19 @@ static int create_segments(size_t requested_size, zend_shared_segment ***shared_
                *error_in = "MapViewOfFile";
                return ALLOC_FAILURE;
        } else {
-               ((void**)mapping_base)[0] = mapping_base;
-               ((void**)mapping_base)[1] = (void*)execute_ex;
-               ((char*)shared_segment->p) += ACCEL_BASE_POINTER_SIZE;
+               char *mmap_base_file = get_mmap_base_file();
+               void *execute_ex_base = (void *)execute_ex;
+               FILE *fp = fopen(mmap_base_file, "w");
+               if (!fp) {
+                       err = GetLastError();
+                       zend_shared_alloc_unlock_win32();
+                       zend_win_error_message(ACCEL_LOG_WARNING, mmap_base_file, err);
+                       zend_win_error_message(ACCEL_LOG_FATAL, "Unable to write base address", err);
+                       return ALLOC_FAILURE;
+               }
+               fprintf(fp, "%p\n", mapping_base);
+               fprintf(fp, "%p\n", execute_ex_base);
+               fclose(fp);
        }
 
        shared_segment->pos = 0;