Skip to content

Commit

Permalink
copy: bail out on non-copyable literal with info instead of asserting
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Nov 19, 2024
1 parent dfd071b commit 71cae13
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static zend_live_range* pmmpthread_copy_live(zend_live_range *old, int end) {
} /* }}} */

/* {{{ */
static zval* pmmpthread_copy_literals(const pmmpthread_ident_t* owner, zval *old, int last, void *memory) {
static zval* pmmpthread_copy_literals(const pmmpthread_ident_t* owner, zval *old, int last, void *memory, zend_string *func_name, zend_string *filename, uint32_t lineno) {
zval *literals = (zval*) memory;
zval *literal = literals,
*end = literals + last;
Expand All @@ -352,8 +352,14 @@ static zval* pmmpthread_copy_literals(const pmmpthread_ident_t* owner, zval *old
memcpy(memory, old, sizeof(zval) * last);
while (literal < end) {
if (pmmpthread_copy_zval(owner, literal, old_literal) == FAILURE) {
ZEND_ASSERT(0); //literals should always be copyable
ZVAL_NULL(literal);
zend_error_at_noreturn(
E_CORE_ERROR,
filename,
lineno,
"pmmpthread encountered a non-copyable literal of type %s in function %s",
zend_zval_type_name(old_literal),
ZSTR_VAL(func_name)
);
}
old_literal++;
literal++;
Expand Down Expand Up @@ -603,7 +609,7 @@ static inline zend_function* pmmpthread_copy_user_function(const pmmpthread_iden
}
#endif

if (op_array->literals) op_array->literals = pmmpthread_copy_literals (owner, literals, op_array->last_literal, literals_memory);
if (op_array->literals) op_array->literals = pmmpthread_copy_literals (owner, literals, op_array->last_literal, literals_memory, op_array->function_name, op_array->filename, op_array->line_start);

op_array->opcodes = pmmpthread_copy_opcodes(op_array, literals, opcodes_memory);

Expand Down

0 comments on commit 71cae13

Please sign in to comment.