|
10 | 10 | #include <dlfcn.h> // for dlsym
|
11 | 11 | #endif
|
12 | 12 |
|
13 |
| -#if PHP_VERSION_ID >= 70400 |
| 13 | +#if PHP_VERSION_ID >= 70400 && PHP_VERSION_ID < 80400 |
14 | 14 | #define CFG_NEED_OPCODE_HANDLERS 1
|
15 | 15 | #else
|
16 | 16 | #define CFG_NEED_OPCODE_HANDLERS 0
|
@@ -108,23 +108,42 @@ static void ddog_php_prof_install_opcode_handlers(uint32_t php_version_id) {
|
108 | 108 | */
|
109 | 109 | user_opcode_handler_t dispatch_handler = (user_opcode_handler_t)ddog_php_prof_opcode_dispatch;
|
110 | 110 |
|
| 111 | +#if PHP_VERSION_ID < 80100 |
111 | 112 | /* Issue is fixed in 8.0.26:
|
112 | 113 | * https://github.com/php/php-src/commit/26c7c82d32dad841dd151ebc6a31b8ea6f93f94a
|
113 | 114 | */
|
114 | 115 | if (php_version_id < 80026 && zend_get_user_opcode_handler(ZEND_GENERATOR_CREATE) == NULL) {
|
115 | 116 | zend_set_user_opcode_handler(ZEND_GENERATOR_CREATE, dispatch_handler);
|
116 | 117 | }
|
| 118 | +#endif |
117 | 119 |
|
| 120 | +#if PHP_VERSION_ID < 80400 |
118 | 121 | /* Part of the issue was fixed in 8.0.12:
|
119 | 122 | * https://github.com/php/php-src/commit/ec54ffad1e3b15fedfd07f7d29d97ec3e8d1c45a
|
120 | 123 | * However, the fix is not complete as it's possible for the opcode to
|
121 | 124 | * call `zend_array_dup()` before the `SAVE_OPLINE()`.
|
| 125 | + * |
| 126 | + * This was finally fixed with https://github.com/php/php-src/pull/12758 in |
| 127 | + * PHP 8.1.27, 8.2.14 and 8.3.1 |
122 | 128 | */
|
123 |
| - if (zend_get_user_opcode_handler(ZEND_BIND_STATIC) == NULL) { |
| 129 | + if ((php_version_id < 80127 || |
| 130 | + (php_version_id >= 80200 && php_version_id < 80214) || |
| 131 | + php_version_id == 80300) && |
| 132 | + zend_get_user_opcode_handler(ZEND_BIND_STATIC) == NULL) |
| 133 | + { |
124 | 134 | zend_set_user_opcode_handler(ZEND_BIND_STATIC, dispatch_handler);
|
125 | 135 | }
|
126 |
| -#if PHP_VERSION_ID >= 80400 |
127 |
| -#error Check if ZEND_BIND_STATIC needs an opcode handler still. Possibly update things like CFG_NEED_OPCODE_HANDLERS as well. |
| 136 | + |
| 137 | + /* This was fixed with https://github.com/php/php-src/pull/12768 in |
| 138 | + * PHP 8.1.27, 8.2.14 and 8.3.1 |
| 139 | + */ |
| 140 | + if ((php_version_id < 80127 || |
| 141 | + (php_version_id >= 80200 && php_version_id < 80214) || |
| 142 | + php_version_id == 80300) && |
| 143 | + zend_get_user_opcode_handler(ZEND_FUNC_GET_ARGS) == NULL) |
| 144 | + { |
| 145 | + zend_set_user_opcode_handler(ZEND_FUNC_GET_ARGS, dispatch_handler); |
| 146 | + } |
128 | 147 | #endif
|
129 | 148 | }
|
130 | 149 | #endif
|
|
0 commit comments