[php-src] PR #16609: Use ZendMM in ext-gmp
| From: | nielsdos | Date: | Sat, 26 Oct 2024 09:31:27 +0000 |
| Subject: | [php-src] PR #16609: Use ZendMM in ext-gmp | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-29409@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/16609
Author: nielsdos
cc @cmb69 I think I found a solution for using ZendMM anyway even when the library uses true
globals. I took your patch and extended it. There's probably still some room for improvement.
There's also a test failure because now one test hits the memory limit.
While libgmp uses true globals to track the allocator, and is therefore not safe to use in a
threaded environment, we can make use of a thread-local variable that indicates whether the current
thread is currently performing a PHP request. We set this TLS global to true if it is in RINIT, and
set it to false in post-RSHUTDOWN. This ensures that any (de)allocation during the request will go
through ZendMM while keeping it possible for this thread to be reused or for other threads using
libgmp.