Skip to content

Release request: 6.3.0 corrupts the heap under ZTS (FrankenPHP worker mode); fixed on develop by cd2a396 #2976

Open

Description

@francisrath

Hi! In ZTS builds, 6.3.0 corrupts the heap (zend_mm_heap corrupted) when several threads create Redis objects at the same time. FrankenPHP worker mode is where this shows up. develop already fixes it, but no release has the fix yet. Could you tag a 6.3.1 (or a patch release) that includes it?

Repro. Two or more FrankenPHP worker threads under concurrent load. No connection or command is needed:

<?php // worker.php
$handler = static function (): void {
    $redis = new \Redis();
    echo 'ok';
};
while (\frankenphp_handle_request($handler));
{
	frankenphp {
		num_threads 4
		worker /app/public/worker.php 2
	}
}
:8080 {
	root /app/public
	php_server
}
FROM dunglas/frankenphp:1-php8.5-alpine
RUN install-php-extensions redis

With oha -z 30s -c 2 http://127.0.0.1:8080/, the process exits with zend_mm_heap corrupted after a few thousand requests.

Build Result
6.3.0, PHP 8.5.12 ZTS, FrankenPHP 1.13.4 crash (~2–10 k requests)
6.3.0, PHP 8.4.27 ZTS crash
6.2.0, PHP 8.4.27 ZTS crash
6.3.0, a single worker thread, or FrankenPHP classic mode stable
6.3.0, one Redis object created once and reused stable
develop @ fc948db stable (1.6 M requests at c=100)

Cause. git bisect (6.3.0 → develop) lands on cd2a396 from #2879, "Initialize global object handlers once not per object creation". Before that commit, create_redis_object() memcpys into the process-global redis_object_handlers every time a Redis object is created. Under ZTS that rewrites the struct while other threads read free_obj from it. So #2879 fixes the crash already; it just hasn't been released.

The same pattern looks like it was in create_cluster_context (RedisCluster) before #2879, so RedisCluster should be affected the same way. I haven't tested that.

Thanks for phpredis!

Activity

  1. michael-grunder commented on Nov 3, 2026

    @michael-grunder
    Member

    A release makes sense. There have been a huge number of changes since 6.3.0 so I will probably want to do a release candidate.

  2. temp commented on Nov 12, 2026

    @temp

    +1 for a release candidate. It would also unblock PHP 8.6: 6.3.0 does not compile against 8.6.0RC5, because 8.6 removed XtOffsetOf and INI_STR:

    common.h:16:73: error: implicit declaration of function 'XtOffsetOf'; did you mean 'offsetof'?
    library.c:142:53: error: implicit declaration of function 'INI_STR'; did you mean 'Z_STR'?
    

    develop no longer uses either macro since #2888, so an RC would let people start testing their apps on 8.6 ahead of GA (and let installers such as install-php-extensions enable redis for 8.6).

  3. tacman commented on Nov 20, 2026

    @tacman

    Thank you for maintaining phpredis.

    A second reason for a new release: PHP 8.6.0 is now out. The latest tag, 6.3.0, does not compile on it (INI_STR and zval_dtor are removed), while develop builds and loads on 8.6.0 (tested on macOS arm64). A tag that includes the 8.6 fixes would let pie install phpredis/phpredis work on 8.6 without building from develop.

    Happy to test a release candidate if that helps.

  4. michael-grunder commented on Nov 20, 2026

    @michael-grunder
    Member

    There's a 6.4.0RC1 issue and branch.

    It has all of the fixes and php 8.6 support as well as several commits to maintain 6.3.0 compatibility since we can't break that until 7.

    I should be able to tag and release it early next week.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions