Skip to content

Commit d59ae93

Browse files
committed
Cleanup SSA(s) in case of fatal error during tracing JIT
This fixes segfault becuse of UAF in ext/standard/tests/gh14643_longname.phpt
1 parent 93740d0 commit d59ae93

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4064,6 +4064,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
40644064
zend_jit_trace_rec *p;
40654065
zend_jit_op_array_trace_extension *jit_extension;
40664066
int num_op_arrays = 0;
4067+
bool do_bailout = 0;
40674068
zend_jit_trace_info *t;
40684069
const zend_op_array *op_arrays[ZEND_JIT_TRACE_MAX_FUNCS];
40694070
uint8_t smart_branch_opcode;
@@ -4094,6 +4095,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
40944095

40954096
checkpoint = zend_arena_checkpoint(CG(arena));
40964097

4098+
zend_try {
4099+
40974100
ssa = zend_jit_trace_build_tssa(trace_buffer, parent_trace, exit_num, script, op_arrays, &num_op_arrays);
40984101

40994102
if (!ssa) {
@@ -7286,6 +7289,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
72867289
zend_string_release(name);
72877290
}
72887291

7292+
} zend_catch {
7293+
do_bailout = 1;
7294+
} zend_end_try();
7295+
72897296
jit_cleanup:
72907297
/* Clean up used op_arrays */
72917298
while (num_op_arrays > 0) {
@@ -7306,6 +7313,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
73067313
JIT_G(current_frame) = NULL;
73077314
JIT_G(current_trace) = NULL;
73087315

7316+
if (do_bailout) {
7317+
zend_bailout();
7318+
}
7319+
73097320
return handler;
73107321
}
73117322

0 commit comments

Comments
 (0)