summaryrefslogtreecommitdiffstats
path: root/apcu-upstream.patch
blob: 72e15fd0231676b445926e7898c7f56a15121a7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From 563c4573d439d5371f7f331b5117b7e6b648ed17 Mon Sep 17 00:00:00 2001
From: Tyson Andre <tysonandre775@hotmail.com>
Date: Sun, 24 Jul 2016 19:05:10 -0700
Subject: [PATCH] Fixes #188: Fix Segfault in ZTS build when locking

In ZTS builds with static TSRMLS,
blocking interruptions requires TSRMLS to be initialized.

(WLOCK will block signal interruptions, then acquire a lock)

The code initialized it in RINIT (per-request), but did not initialize
it in MINIT(module init).
But module init needed to lock in order to not be interrupted while
allocating an arena in shared memory.

Fixed this by calling ZEND_TSRMLS_CACHE_UPDATE();

Other extensions do this in MINIT in both php-7.0 and php-7.1
E.g.  https://github.com/php/php-src/blob/PHP-7.0.9/ext/mbstring/mbstring.c#L1550
---
 php_apc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/php_apc.c b/php_apc.c
index 83fd758..d79338e 100644
--- a/php_apc.c
+++ b/php_apc.c
@@ -210,6 +210,9 @@ static PHP_MINFO_FUNCTION(apcu)
 /* {{{ PHP_MINIT_FUNCTION(apcu) */
 static PHP_MINIT_FUNCTION(apcu)
 {
+#if defined(ZTS) && defined(COMPILE_DL_APCU)
+    ZEND_TSRMLS_CACHE_UPDATE();
+#endif
     ZEND_INIT_MODULE_GLOBALS(apcu, php_apc_init_globals, NULL);
 
     REGISTER_INI_ENTRIES();