[php-src] Issue #12762: PHP 8.3 not working on Windows 7

From: Date: Fri, 24 Nov 2023 09:50:29 +0000
Subject: [php-src] Issue #12762: PHP 8.3 not working on Windows 7
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245881@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12762 Author: nono303 ### Description Hi, Just trying to run PHP 8.3.0 on Windows 7 (after successfully compiling it on Win11 vs17 x64) and it's failed with message ![image](https://github.com/php/php-src/assets/2869665/c29be9bc-366b-4719-a74f-b98fce5aeb2b) According to https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentthreadstacklimits it's normal as requirements are: - Minimum supported client Windows 8 [desktop apps | UWP apps] - Minimum supported server Windows Server 2012 [desktop apps | UWP apps] It had also been clearly mentioned on https://github.com/php/php-src/pull/9104#issuecomment-1627481475 Looking to the source code, I found GetCurrentThreadStackLimits used in Zend/zend_call_stack.c Based on https://stackoverflow.com/a/52404641 I dirtily applied the patch and **now PHP 8.3.0 run fine on windows 7** ```patch diff --git "a/Zend/zend_call_stack.c" "b/Zend/zend_call_stack.c" index 06ee521911..9fc2b570bc 100644 --- "a/Zend/zend_call_stack.c" +++ "b/Zend/zend_call_stack.c" @@ -376,7 +376,22 @@ static bool zend_call_stack_get_win32(zend_call_stack *stack) * v Lower addresses v */ - GetCurrentThreadStackLimits(&low_limit, &high_limit); + static void (WINAPI* GetCurrentThreadStackLimits)(PULONG_PTR , PULONG_PTR); + if (!GetCurrentThreadStackLimits) { + *(void**)&GetCurrentThreadStackLimits = GetProcAddress(GetModuleHandle(L"kernel32"), "GetCurrentThreadStackLimits"); + if (!GetCurrentThreadStackLimits) { + NT_TIB* tib = (NT_TIB*)NtCurrentTeb(); + high_limit = (ULONG_PTR)tib->StackBase; + MEMORY_BASIC_INFORMATION mbi; + if (VirtualQuery(tib->StackLimit, &mbi, sizeof(mbi))) { + low_limit = (ULONG_PTR)mbi.AllocationBase; + } + } else { + GetCurrentThreadStackLimits(&low_limit, &high_limit); + } + } else { + GetCurrentThreadStackLimits(&low_limit, &high_limit); + } result_size = VirtualQuery((void*)low_limit, &uncommitted_region, sizeof(uncommitted_region)); ``` ![image](https://github.com/php/php-src/assets/2869665/9b42112a-7eff-47ab-bbbe-38418c9373bf) So... Does this patch (or a corrected one as I don't really master all the elements) would make sense to ensure PHP a long life on old Windows OS ? ### PHP Version PHP 8.3.0 ### Operating System Windows 7 x64

« previous php.bugs (#245881) next »