Skip to content

Commit 09f047a

Browse files
committed
Merge branch 'master' into jit-dynasm
* master: Changed the way VM accesses constant operands in 64-bit builds. Fixed rarely possible use-after-free Fixed invalid type Bumped ext/oci8 version Use dereferenced value Fixed compilation errors Restored code for BOOL variables Change EXTENSIONS file encoding from iso-8859-1 to utf-8 Fixed few ext/oci8 bugs
2 parents 7f64a7f + e70618a commit 09f047a

32 files changed

+1356
-1188
lines changed

EXTENSIONS

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ MAINTENANCE: Unknown
3737
STATUS: Working
3838
-------------------------------------------------------------------------------
3939
EXTENSION: cli
40-
MAINTENANCE: Marcus Boerger <helly@php.net>, Edin Kadribasic <edink@php.net>
40+
MAINTENANCE: Marcus Börger <helly@php.net>, Edin Kadribasic <edink@php.net>
4141
STATUS: Working
4242
SINCE: 4.3.0
4343
-------------------------------------------------------------------------------
@@ -68,7 +68,7 @@ STATUS: 5.6
6868

6969
-------------------------------------------------------------------------------
7070
EXTENSION: dba
71-
PRIMARY MAINTAINER: Marcus B�rger <helly@php.net>,Christopher Jones <sixd@php.net>, Pierre-Alain Joye <pajoye@php.net>
71+
PRIMARY MAINTAINER: Marcus Börger <helly@php.net>,Christopher Jones <sixd@php.net>, Pierre-Alain Joye <pajoye@php.net>
7272
MAINTENANCE: Maintained
7373
STATUS: Working
7474
COMMENT: DBM abstraction for db2, db3, db4, dbm, ndbm, gdbm, ini
@@ -79,13 +79,13 @@ MAINTENANCE: Odd fixes
7979
STATUS: Working
8080
-------------------------------------------------------------------------------
8181
EXTENSION: mysqli
82-
PRIMARY MAINTAINER: Georg Richter <georg@php.net>, Andrey Hristov <andrey@php.net>, Johannes Schl�ter <johannes@php.net>, Ulf Wendel <uw@php.net>
82+
PRIMARY MAINTAINER: Georg Richter <georg@php.net>, Andrey Hristov <andrey@php.net>, Johannes Schlüter <johannes@php.net>, Ulf Wendel <uw@php.net>
8383
MAINTENANCE: Maintained
8484
STATUS: Working
8585
SINCE: 5.0
8686
-------------------------------------------------------------------------------
8787
EXTENSION: mysqlnd
88-
PRIMARY MAINTAINER: Andrey Hristov <andrey@php.net>, Johannes Schl�ter <johannes@php.net>, Ulf Wendel <uw@php.net>
88+
PRIMARY MAINTAINER: Andrey Hristov <andrey@php.net>, Johannes Schlüter <johannes@php.net>, Ulf Wendel <uw@php.net>
8989
MAINTENANCE: Maintained
9090
STATUS: Working
9191
SINCE: 5.3
@@ -99,7 +99,7 @@ EXTENSION: odbc
9999
PRIMARY MAINTAINER: Daniel R. Kalowsky <kalowsky@php.net>
100100
MAINTENANCE: Maintained
101101
STATUS: Working
102-
COMMENT: Working
102+
COMMENT: Working
103103
-------------------------------------------------------------------------------
104104
EXTENSION: pdo
105105
PRIMARY MAINTAINER: Ilia Alshanetsky <iliaa@php.net>, Wez Furlong <wez@php.net>
@@ -120,7 +120,7 @@ STATUS: Working
120120
SINCE: 5.1
121121
-------------------------------------------------------------------------------
122122
EXTENSION: pdo_mysql
123-
PRIMARY MAINTAINER: Ilia Alshanetsky <iliaa@php.net>, Johannes Schl�ter <johannes@php.net>, Andrey Hristov <andrey@php.net>, Ulf Wendel <uw@php.net>
123+
PRIMARY MAINTAINER: Ilia Alshanetsky <iliaa@php.net>, Johannes Schlüter <johannes@php.net>, Andrey Hristov <andrey@php.net>, Ulf Wendel <uw@php.net>
124124
MAINTENANCE: Odd fixes
125125
STATUS: Working
126126
SINCE: 5.1
@@ -150,7 +150,7 @@ STATUS: Working
150150
SINCE: 5.1
151151
-------------------------------------------------------------------------------
152152
EXTENSION: pgsql
153-
PRIMARY MAINTAINER: Marcus Boerger <helly@php.net>, Yasuo Ohgaki <yohgaki@php.net>
153+
PRIMARY MAINTAINER: Marcus Börger <helly@php.net>, Yasuo Ohgaki <yohgaki@php.net>
154154
MAINTENANCE: Maintained
155155
STATUS: Working
156156
COMMENT: Use PostgreSQL 7.0.x or later. PostgreSQL 6.5.3 or less have fatal bug.
@@ -168,13 +168,13 @@ COMMENT: Integrates SQLite 3 embeddable SQL database engine.
168168

169169
-------------------------------------------------------------------------------
170170
EXTENSION: dom
171-
PRIMARY MAINTAINER: Christian Stocker <chregu@php.net>, Rob Richards <rrichards@php.net>, Marcus Boerger <helly@php.net>
171+
PRIMARY MAINTAINER: Christian Stocker <chregu@php.net>, Rob Richards <rrichards@php.net>, Marcus Börger <helly@php.net>
172172
MAINTENANCE: Maintained
173173
STATUS: Working
174174
SINCE: 5.0
175175
-------------------------------------------------------------------------------
176176
EXTENSION: simplexml
177-
PRIMARY MAINTAINER: Marcus Boerger <helly@php.net>
177+
PRIMARY MAINTAINER: Marcus Börger <helly@php.net>
178178
MAINTENANCE: Maintained
179179
STATUS: Working
180180
SINCE: 5.0
@@ -195,12 +195,12 @@ MAINTENANCE: Maintained
195195
STATUS: Working
196196
-------------------------------------------------------------------------------
197197
EXTENSION: libxml
198-
PRIMARY MAINTAINER: Rob Richards <rrichards@php.net>, Christian Stocker <chregu@php.net>
198+
PRIMARY MAINTAINER: Rob Richards <rrichards@php.net>, Christian Stocker <chregu@php.net>
199199
MAINTENANCE: Maintained
200200
STATUS: Working
201201
-------------------------------------------------------------------------------
202202
EXTENSION: xmlreader
203-
PRIMARY MAINTAINER: Rob Richards <rrichards@php.net>, Christian Stocker <chregu@php.net>
203+
PRIMARY MAINTAINER: Rob Richards <rrichards@php.net>, Christian Stocker <chregu@php.net>
204204
MAINTENANCE: Maintained
205205
STATUS: Working
206206
-------------------------------------------------------------------------------
@@ -335,7 +335,7 @@ STATUS: Working
335335
SINCE: 5.2
336336
-------------------------------------------------------------------------------
337337
EXTENSION: ldap
338-
PRIMARY MAINTAINER: Stig Venaas <venaas@php.net>, Douglas Goldstein <cardoe@php.net>, Pierre-Alain Joye <pajoye@php.net>, C�me Bernigaud <mcmic@php.net>
338+
PRIMARY MAINTAINER: Stig Venaas <venaas@php.net>, Douglas Goldstein <cardoe@php.net>, Pierre-Alain Joye <pajoye@php.net>, Côme Bernigaud <mcmic@php.net>
339339
MAINTENANCE: Maintained
340340
STATUS: Working
341341
-------------------------------------------------------------------------------
@@ -367,13 +367,13 @@ MAINTENANCE: Maintained
367367
STATUS: Working
368368
-------------------------------------------------------------------------------
369369
EXTENSION: phar
370-
PRIMARY MAINTAINER: Greg Beaver <cellog@php.net>, Marcus B�rger <helly@php.net>, Steph Fox <sfox@php.net>
370+
PRIMARY MAINTAINER: Greg Beaver <cellog@php.net>, Marcus Börger <helly@php.net>, Steph Fox <sfox@php.net>
371371
MAINTENANCE: Maintained
372372
STATUS: Working
373373
SINCE: 5.3
374374
-------------------------------------------------------------------------------
375375
EXTENSION: posix
376-
PRIMARY MAINTAINER: Kristian K�hntopp <kris@koehntopp.de>
376+
PRIMARY MAINTAINER: Kristian Köhntopp <kris@koehntopp.de>
377377
MAINTENANCE: Maintained
378378
STATUS: Working
379379
-------------------------------------------------------------------------------
@@ -388,12 +388,12 @@ MAINTENANCE: Unknown
388388
STATUS: Working
389389
-------------------------------------------------------------------------------
390390
EXTENSION: recode
391-
PRIMARY MAINTAINER: Kristian K�hntopp <kris@koehntopp.de>
391+
PRIMARY MAINTAINER: Kristian Köhntopp <kris@koehntopp.de>
392392
MAINTENANCE: Maintained
393393
STATUS: Working
394394
-------------------------------------------------------------------------------
395395
EXTENSION: reflection
396-
PRIMARY MAINTAINER: Marcus B�rger <helly@php.net>, Johannes Schl�ter <johannes@php.net>
396+
PRIMARY MAINTAINER: Marcus Börger <helly@php.net>, Johannes Schlüter <johannes@php.net>
397397
MAINTENANCE: Maintained
398398
STATUS: Working
399399
-------------------------------------------------------------------------------
@@ -426,7 +426,7 @@ STATUS: Working
426426
SINCE: 7.2.0
427427
-------------------------------------------------------------------------------
428428
EXTENSION: spl
429-
PRIMARY MAINTAINER: Marcus Boerger <helly@php.net>, Etienne Kneuss <colder@php.net>
429+
PRIMARY MAINTAINER: Marcus Börger <helly@php.net>, Etienne Kneuss <colder@php.net>
430430
MAINTENANCE: Maintained
431431
STATUS: Working
432432
SINCE: 5.0.0

UPGRADING.INTERNALS

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ PHP 7.2 INTERNALS UPGRADE NOTES
1010
g. ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX changed
1111
h. valid_symbol_table removed
1212
i. array_init() and array_init_size()
13+
j. Run-time constant operand addressing
1314

1415
2. Build system changes
1516
a. Unix build system changes
@@ -52,6 +53,24 @@ PHP 7.2 INTERNALS UPGRADE NOTES
5253
i. array_init() and array_init_size() are not functions anymore.
5354
They don't return any values.
5455

56+
j. In 64-bit builds PHP-7.2 and below used relative run-time constant operand
57+
addressing. E.g. opline->op1.constant kept an offset from start of literals
58+
table - op_array->literals. To speedup access op_array->literals was cached
59+
in execute_data->literals. So the resulting address calculated as
60+
EX(literals) + opline->op1.constant.
61+
62+
Now at run-time literals allocated close to opcodes, and addressed
63+
relatively from current opline. This eliminates load of EX(literals) on
64+
each constant access as well as EX(literals) initialization on each call.
65+
66+
As result some related macros were removed (ZEND_EX_USE_LITERALS,
67+
EX_LOAD_LITERALS, EX_LITERALS, RT_CONSTANT_EX, EX_CONSTANT) or changed
68+
(RT_CONSTANT, ZEND_PASS_TWO_UPDATE_CONSTANT, ZEND_PASS_TWO_UNDO_CONSTANT).
69+
This change way affect only some "system" extensions. EX_LITERALS,
70+
RT_CONSTANT_EX, EX_CONSTANT should be substituted by RT_CONSTANT than now
71+
use "opline" (instead of "op_array") as first argument.
72+
73+
5574
========================
5675
2. Build system changes
5776
========================

Zend/zend_compile.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ ZEND_API int do_bind_function(const zend_op_array *op_array, const zend_op *opli
10821082
lcname = CT_CONSTANT_EX(op_array, opline->op1.constant);
10831083
rtd_key = lcname + 1;
10841084
} else {
1085-
lcname = RT_CONSTANT(op_array, opline->op1);
1085+
lcname = RT_CONSTANT(opline, opline->op1);
10861086
rtd_key = lcname + 1;
10871087
}
10881088

@@ -1123,7 +1123,7 @@ ZEND_API zend_class_entry *do_bind_class(const zend_op_array* op_array, const ze
11231123
lcname = CT_CONSTANT_EX(op_array, opline->op1.constant);
11241124
rtd_key = lcname + 1;
11251125
} else {
1126-
lcname = RT_CONSTANT(op_array, opline->op1);
1126+
lcname = RT_CONSTANT(opline, opline->op1);
11271127
rtd_key = lcname + 1;
11281128
}
11291129
ce = zend_hash_find_ptr(class_table, Z_STR_P(rtd_key));
@@ -1158,7 +1158,7 @@ ZEND_API zend_class_entry *do_bind_inherited_class(const zend_op_array *op_array
11581158
lcname = CT_CONSTANT_EX(op_array, opline->op1.constant);
11591159
rtd_key = lcname + 1;
11601160
} else {
1161-
lcname = RT_CONSTANT(op_array, opline->op1);
1161+
lcname = RT_CONSTANT(opline, opline->op1);
11621162
rtd_key = lcname + 1;
11631163
}
11641164

@@ -1304,7 +1304,8 @@ ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array) /* {{
13041304

13051305
CG(in_compilation) = 1;
13061306
while (opline_num != (uint32_t)-1) {
1307-
zval *parent_name = RT_CONSTANT(op_array, op_array->opcodes[opline_num-1].op2);
1307+
const zend_op *opline = &op_array->opcodes[opline_num-1];
1308+
zval *parent_name = RT_CONSTANT(opline, opline->op2);
13081309
if ((ce = zend_lookup_class_ex(Z_STR_P(parent_name), parent_name + 1, 0)) != NULL) {
13091310
do_bind_inherited_class(op_array, &op_array->opcodes[opline_num], EG(class_table), ce, 0);
13101311
}

Zend/zend_compile.h

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ typedef struct _zend_op zend_op;
5959
#if SIZEOF_SIZE_T == 4
6060
# define ZEND_USE_ABS_JMP_ADDR 1
6161
# define ZEND_USE_ABS_CONST_ADDR 1
62-
# define ZEND_EX_USE_LITERALS 0
6362
# define ZEND_EX_USE_RUN_TIME_CACHE 1
6463
#else
6564
# define ZEND_USE_ABS_JMP_ADDR 0
6665
# define ZEND_USE_ABS_CONST_ADDR 0
67-
# define ZEND_EX_USE_LITERALS 1
6866
# define ZEND_EX_USE_RUN_TIME_CACHE 1
6967
#endif
7068

@@ -470,9 +468,6 @@ struct _zend_execute_data {
470468
#if ZEND_EX_USE_RUN_TIME_CACHE
471469
void **run_time_cache; /* cache op_array->run_time_cache */
472470
#endif
473-
#if ZEND_EX_USE_LITERALS
474-
zval *literals; /* cache op_array->literals */
475-
#endif
476471
};
477472

478473
#define ZEND_CALL_FUNCTION (0 << 0)
@@ -616,64 +611,38 @@ struct _zend_execute_data {
616611
#if ZEND_USE_ABS_CONST_ADDR
617612

618613
/* run-time constant */
619-
# define RT_CONSTANT_EX(base, node) \
614+
# define RT_CONSTANT(opline, node) \
620615
(node).zv
621616

622617
/* convert constant from compile-time to run-time */
623-
# define ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, node) do { \
618+
# define ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, node) do { \
624619
(node).zv = CT_CONSTANT_EX(op_array, (node).constant); \
625620
} while (0)
626621

627-
/* convert constant back from run-time to compile-time */
628-
# define ZEND_PASS_TWO_UNDO_CONSTANT(op_array, node) do { \
629-
(node).constant = (node).zv - (op_array)->literals; \
630-
} while (0)
631-
632622
#else
633623

624+
/* At run-time, constants are allocated together with op_array->opcodes
625+
* and addressed relatively to current opline.
626+
*/
627+
634628
/* run-time constant */
635-
# define RT_CONSTANT_EX(base, node) \
636-
((zval*)(((char*)(base)) + (node).constant))
629+
# define RT_CONSTANT(opline, node) \
630+
((zval*)(((char*)(opline)) + (int32_t)(node).constant))
637631

638632
/* convert constant from compile-time to run-time */
639-
# define ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, node) do { \
640-
(node).constant *= sizeof(zval); \
641-
} while (0)
642-
643-
/* convert constant back from run-time to compile-time (do nothing) */
644-
# define ZEND_PASS_TWO_UNDO_CONSTANT(op_array, node) do { \
645-
(node).constant /= sizeof(zval); \
633+
# define ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, node) do { \
634+
(node).constant = \
635+
(((char*)CT_CONSTANT_EX(op_array, (node).constant)) - \
636+
((char*)opline)); \
646637
} while (0)
647638

648639
#endif
649640

650-
#if ZEND_EX_USE_LITERALS
651-
652-
# define EX_LITERALS() \
653-
EX(literals)
654-
655-
# define EX_LOAD_LITERALS(op_array) do { \
656-
EX(literals) = (op_array)->literals; \
657-
} while (0)
658-
659-
#else
660-
661-
# define EX_LITERALS() \
662-
EX(func)->op_array.literals
663-
664-
# define EX_LOAD_LITERALS(op_array) do { \
641+
/* convert constant back from run-time to compile-time */
642+
#define ZEND_PASS_TWO_UNDO_CONSTANT(op_array, opline, node) do { \
643+
(node).constant = RT_CONSTANT(opline, node) - (op_array)->literals; \
665644
} while (0)
666645

667-
#endif
668-
669-
/* run-time constant */
670-
#define RT_CONSTANT(op_array, node) \
671-
RT_CONSTANT_EX((op_array)->literals, node)
672-
673-
/* constant in currently executed function */
674-
#define EX_CONSTANT(node) \
675-
RT_CONSTANT_EX(EX_LITERALS(), node)
676-
677646
#if ZEND_EX_USE_RUN_TIME_CACHE
678647

679648
# define EX_RUN_TIME_CACHE() \

0 commit comments

Comments
 (0)