-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix GH-13834: Applying non-zero offset 36 to null pointer in zend_jit.c #13846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
7b6523c
befd724
09be586
1e7a540
f7c9a5c
a37ee2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,19 +172,20 @@ static zend_always_inline uint32_t get_ssa_var_info(const zend_ssa *ssa, int ssa | |
} | ||
|
||
#define DEFINE_SSA_OP_INFO(opN) \ | ||
static zend_always_inline uint32_t _ssa_##opN##_info(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \ | ||
static zend_always_inline uint32_t _ssa_##opN##_info(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op, size_t offset) \ | ||
{ \ | ||
opline += offset; \ | ||
if (opline->opN##_type == IS_CONST) { \ | ||
return _const_op_type(CRT_CONSTANT(opline->opN)); \ | ||
} else { \ | ||
return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_use : -1); \ | ||
return get_ssa_var_info(ssa, ssa->var_info ? (ssa_op + offset)->opN##_use : -1); \ | ||
} \ | ||
} \ | ||
|
||
#define DEFINE_SSA_OP_DEF_INFO(opN) \ | ||
static zend_always_inline uint32_t _ssa_##opN##_def_info(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \ | ||
static zend_always_inline uint32_t _ssa_##opN##_def_info(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op, size_t offset) \ | ||
{ \ | ||
return get_ssa_var_info(ssa, ssa->var_info ? ssa_op->opN##_def : -1); \ | ||
return get_ssa_var_info(ssa, ssa->var_info ? (ssa_op + offset)->opN##_def : -1); \ | ||
} \ | ||
|
||
|
||
|
@@ -195,16 +196,16 @@ DEFINE_SSA_OP_DEF_INFO(op1) | |
DEFINE_SSA_OP_DEF_INFO(op2) | ||
DEFINE_SSA_OP_DEF_INFO(result) | ||
|
||
#define OP1_INFO() (_ssa_op1_info(op_array, ssa, opline, ssa_op)) | ||
#define OP2_INFO() (_ssa_op2_info(op_array, ssa, opline, ssa_op)) | ||
#define OP1_DATA_INFO() (_ssa_op1_info(op_array, ssa, (opline+1), (ssa_op+1))) | ||
#define OP2_DATA_INFO() (_ssa_op2_info(op_array, ssa, (opline+1), (ssa_op+1))) | ||
Comment on lines
-200
to
-201
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you change this into -#define OP1_DATA_INFO() (_ssa_op1_info(op_array, ssa, (opline+1), (ssa_op+1)))
-#define OP2_DATA_INFO() (_ssa_op2_info(op_array, ssa, (opline+1), (ssa_op+1)))
+#define OP1_DATA_INFO() (_ssa_op1_info(op_array, ssa, (opline+1), ssa_op ? (ssa_op+1) : NULL))
+#define OP2_DATA_INFO() (_ssa_op2_info(op_array, ssa, (opline+1), ssa_op ? (ssa_op+1) : NULL)) I think this should lead to a simple diff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, done. |
||
#define RES_USE_INFO() (_ssa_result_info(op_array, ssa, opline, ssa_op)) | ||
#define OP1_DEF_INFO() (_ssa_op1_def_info(op_array, ssa, opline, ssa_op)) | ||
#define OP2_DEF_INFO() (_ssa_op2_def_info(op_array, ssa, opline, ssa_op)) | ||
#define OP1_DATA_DEF_INFO() (_ssa_op1_def_info(op_array, ssa, (opline+1), (ssa_op+1))) | ||
#define OP2_DATA_DEF_INFO() (_ssa_op2_def_info(op_array, ssa, (opline+1), (ssa_op+1))) | ||
#define RES_INFO() (_ssa_result_def_info(op_array, ssa, opline, ssa_op)) | ||
#define OP1_INFO() (_ssa_op1_info(op_array, ssa, opline, ssa_op, 0)) | ||
#define OP2_INFO() (_ssa_op2_info(op_array, ssa, opline, ssa_op, 0)) | ||
#define OP1_DATA_INFO() (_ssa_op1_info(op_array, ssa, opline, ssa_op, 1)) | ||
#define OP2_DATA_INFO() (_ssa_op2_info(op_array, ssa, opline, ssa_op, 1)) | ||
#define RES_USE_INFO() (_ssa_result_info(op_array, ssa, opline, ssa_op, 0)) | ||
#define OP1_DEF_INFO() (_ssa_op1_def_info(op_array, ssa, opline, ssa_op, 0)) | ||
#define OP2_DEF_INFO() (_ssa_op2_def_info(op_array, ssa, opline, ssa_op, 0)) | ||
#define OP1_DATA_DEF_INFO() (_ssa_op1_def_info(op_array, ssa, opline, ssa_op, 1)) | ||
#define OP2_DATA_DEF_INFO() (_ssa_op2_def_info(op_array, ssa, opline, ssa_op, 1)) | ||
#define RES_INFO() (_ssa_result_def_info(op_array, ssa, opline, ssa_op, 0)) | ||
|
||
static zend_always_inline bool zend_add_will_overflow(zend_long a, zend_long b) { | ||
return (b > 0 && a > ZEND_LONG_MAX - b) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15240,7 +15240,7 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_ | |
jit->b = -1; | ||
} | ||
} else { | ||
zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes]; | ||
zend_ssa_op *ssa_op = ssa->ops ? &ssa->ops[opline - op_array->opcodes] : NULL; | ||
uint32_t op1_info = OP1_INFO(); | ||
zend_jit_addr op1_addr = OP1_ADDR(); | ||
const zend_op *default_opline = ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value); | ||
|
@@ -16301,7 +16301,7 @@ static int zend_jit_trace_start(zend_jit_ctx *jit, | |
if (parent) { | ||
int i; | ||
int parent_vars_count = parent->exit_info[exit_num].stack_size; | ||
zend_jit_trace_stack *parent_stack = | ||
zend_jit_trace_stack *parent_stack = parent_vars_count == 0 ? NULL : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you fix by this? (this is not related). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After removing |
||
parent->stack_map + | ||
parent->exit_info[exit_num].stack_offset; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer not to change the "public" API prototypes.
Let me think a bit...