Skip to content

Conversation

@EdmondDantes
Copy link

@EdmondDantes EdmondDantes commented Jan 15, 2026

PHP_FUNCTION(socket_wsaprotocol_info_export)
{
 .....
        // allocate Request memory here
	seg_name = zend_strpprintf(0, "php_wsa_for_%u", SOCKETS_G(wsa_child_count)++);
	map = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(WSAPROTOCOL_INFO), ZSTR_VAL(seg_name));
	if (NULL != map) {

        // put to persistent memory array
        zend_hash_add_ptr(&(SOCKETS_G(wsa_info)), seg_name, map);

Memory allocated for the request is destroyed before the SOCKETS_G(wsa_info) array is destructed

If the socket_wsaprotocol_info_release method is not called, the application terminates with the message "zend_mm_heap corrupted"

The code proposed in this patch is not ideal, and it may be worth removing the creation of the array in persistent memory. I do not fully understand the reason why it was done this way. Nevertheless, this code works correctly.

P.S. Apparently, this bug is present in all PHP versions.

@devnexen
Copy link
Member

Hi please target PHP-8.5 (without the last .0) thanks :)

@EdmondDantes EdmondDantes changed the base branch from PHP-8.5.0 to PHP-8.5 January 15, 2026 12:35
Add zend_hash_clean for wsa_info hashtable in PHP_RSHUTDOWN_FUNCTION
to properly cleanup WSA protocol information on Windows during request
shutdown.
@EdmondDantes
Copy link
Author

Hi please target PHP-8.5 (without the last .0) thanks :)

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants