From 8df608aba06b851377a9d6e5a6085541725e11d2 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 5 Feb 2021 14:26:44 +0100 Subject: add patch for PHP 8 / ZTS from https://github.com/scoutapp/scout-apm-php-ext/pull/69 --- 69.patch | 117 +++++++++++++++++++++++++++++++++++++++++++++++++ php-pecl-scoutapm.spec | 14 +++--- 2 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 69.patch diff --git a/69.patch b/69.patch new file mode 100644 index 0000000..3589d4b --- /dev/null +++ b/69.patch @@ -0,0 +1,117 @@ +From 4d1ec38c5cdf104f4167faf47378c4f19e7c25b9 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Fri, 5 Feb 2021 12:05:28 +0100 +Subject: [PATCH 1/3] fix globals init and ZTS + +--- + config.m4 | 2 +- + zend_scoutapm.c | 15 ++++++++++++++- + 2 files changed, 15 insertions(+), 2 deletions(-) + +diff --git a/config.m4 b/config.m4 +index 771fc1d..5e8d1d0 100644 +--- a/config.m4 ++++ b/config.m4 +@@ -80,7 +80,7 @@ if test "$PHP_SCOUTAPM" != "no"; then + STD_CFLAGS="-g -O0 -Wall" + fi + +- PHP_SCOUTAPM_CFLAGS="$STD_CFLAGS $MAINTAINER_CFLAGS" ++ PHP_SCOUTAPM_CFLAGS="-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 $STD_CFLAGS $MAINTAINER_CFLAGS" + + PHP_NEW_EXTENSION(scoutapm, zend_scoutapm.c scout_curl_wrapper.c scout_file_wrapper.c scout_pdo_wrapper.c, + $ext_shared,,$PHP_SCOUTAPM_CFLAGS,,yes) +diff --git a/zend_scoutapm.c b/zend_scoutapm.c +index 739dc66..7139a52 100644 +--- a/zend_scoutapm.c ++++ b/zend_scoutapm.c +@@ -82,6 +82,12 @@ PHP_MINFO_FUNCTION(scoutapm) + php_info_print_table_end(); + } + ++static ++PHP_GINIT_FUNCTION(scoutapm) ++{ ++ scoutapm_globals->handlers_set = 0; ++} ++ + /* scoutapm_module_entry provides the metadata/information for PHP about this PHP module */ + static zend_module_entry scoutapm_module_entry = { + STANDARD_MODULE_HEADER, +@@ -94,7 +100,7 @@ static zend_module_entry scoutapm_module_entry = { + PHP_MINFO(scoutapm), /* module information */ + PHP_SCOUTAPM_VERSION, /* module version */ + PHP_MODULE_GLOBALS(scoutapm), /* module global variables */ +- NULL, ++ PHP_GINIT(scoutapm), /* init global */ + NULL, + NULL, + STANDARD_MODULE_PROPERTIES_EX +@@ -105,6 +111,9 @@ static zend_module_entry scoutapm_module_entry = { + * Instead, see `zend_scoutapm_startup` - we load the module there. + ZEND_GET_MODULE(scoutapm); + */ ++#if defined(COMPILE_DL_SCOUTAPM) && defined(ZTS) ++ZEND_TSRMLS_CACHE_DEFINE() ++#endif + + /* extension_version_info is used by PHP */ + zend_extension_version_info extension_version_info = { +@@ -178,6 +187,10 @@ static PHP_RINIT_FUNCTION(scoutapm) + int handler_index; + zend_class_entry *ce; + ++#if defined(COMPILE_DL_SCOUTAPM) && defined(ZTS) ++ ZEND_TSRMLS_CACHE_UPDATE(); ++#endif ++ + SCOUTAPM_DEBUG_MESSAGE("Initialising stacks..."); + SCOUTAPM_G(observed_stack_frames_count) = 0; + SCOUTAPM_G(observed_stack_frames) = calloc(0, sizeof(scoutapm_stack_frame)); + +From 2794f94a9ce0e30451a2d1fd64701e4500644453 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Fri, 5 Feb 2021 12:15:56 +0100 +Subject: [PATCH 2/3] zero all globals + +--- + zend_scoutapm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/zend_scoutapm.c b/zend_scoutapm.c +index 7139a52..2b70a07 100644 +--- a/zend_scoutapm.c ++++ b/zend_scoutapm.c +@@ -85,7 +85,7 @@ PHP_MINFO_FUNCTION(scoutapm) + static + PHP_GINIT_FUNCTION(scoutapm) + { +- scoutapm_globals->handlers_set = 0; ++ memset(scoutapm_globals, 0, sizeof(zend_scoutapm_globals)); + } + + /* scoutapm_module_entry provides the metadata/information for PHP about this PHP module */ + +From 8330d02f790a0aa6f82a94d13b2b94a9d6f8a109 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Fri, 5 Feb 2021 14:15:59 +0100 +Subject: [PATCH 3/3] missing ZEND_TSRMLS_CACHE_UPDATE in GINIT + +--- + zend_scoutapm.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/zend_scoutapm.c b/zend_scoutapm.c +index 2b70a07..5be730b 100644 +--- a/zend_scoutapm.c ++++ b/zend_scoutapm.c +@@ -85,6 +85,9 @@ PHP_MINFO_FUNCTION(scoutapm) + static + PHP_GINIT_FUNCTION(scoutapm) + { ++#if defined(COMPILE_DL_SCOUTAPM) && defined(ZTS) ++ ZEND_TSRMLS_CACHE_UPDATE(); ++#endif + memset(scoutapm_globals, 0, sizeof(zend_scoutapm_globals)); + } + diff --git a/php-pecl-scoutapm.spec b/php-pecl-scoutapm.spec index f3bd25c..3212b1c 100644 --- a/php-pecl-scoutapm.spec +++ b/php-pecl-scoutapm.spec @@ -18,11 +18,13 @@ Summary: Native Extension Component for ScoutAPM's PHP Agent Name: %{?sub_prefix}php-pecl-%{pecl_name} Version: 1.2.0 -Release: 1%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} +Release: 2%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} Source0: https://pecl.php.net/get/%{pecl_name}-%{version}.tgz License: PHP URL: https://pecl.php.net/package/%{pecl_name} +Patch0: https://patch-diff.githubusercontent.com/raw/scoutapp/scout-apm-php-ext/pull/69.patch + BuildRequires: make BuildRequires: %{?dtsprefix}gcc BuildRequires: %{?scl_prefix}php-devel >= 7.1 @@ -77,6 +79,8 @@ sed -e 's/role="test"/role="src"/' \ -i package.xml pushd NTS +%patch0 -p1 + : Check version extver=$(sed -n '/#define PHP_SCOUTAPM_VERSION /{s/.* "//;s/".*$//;p}' zend_scoutapm.h) if test "x${extver}" != "x%{version}%{?prever}"; then @@ -189,11 +193,7 @@ TEST_PHP_EXECUTABLE=%{__php} \ : Upstream test suite for ZTS extension cd ../ZTS TEST_PHP_ARGS="$DEPS -d zend_extension=%{buildroot}%{php_ztsextdir}/%{pecl_name}.so" \ -%if "%{php_version}" > "8.0" -REPORT_EXIT_STATUS=0 \ -%else REPORT_EXIT_STATUS=1 \ -%endif NO_INTERACTION=1 \ TEST_PHP_EXECUTABLE=%{__ztsphp} \ %{__ztsphp} -n run-tests.php --show-diff @@ -215,6 +215,10 @@ TEST_PHP_EXECUTABLE=%{__ztsphp} \ %changelog +* Fri Feb 5 2021 Remi Collet - 1.2.0-2 +- add patch for PHP 8 / ZTS from + https://github.com/scoutapp/scout-apm-php-ext/pull/69 + * Thu Feb 4 2021 Remi Collet - 1.2.0-1 - update to 1.2.0 - open https://github.com/scoutapp/scout-apm-php-ext/issues/67 -- cgit