Skip to content

Commit

Permalink
rename fatal_error_backtrace -> last_fatal_error_backtrace
Browse files Browse the repository at this point in the history
  • Loading branch information
ericnorris committed Jan 17, 2025
1 parent b1db022 commit 9f29e80
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1465,8 +1465,8 @@ ZEND_API ZEND_COLD void zend_error_zstr_at(
}

// Always clear the last backtrace.
zval_ptr_dtor(&EG(fatal_error_backtrace));
ZVAL_UNDEF(&EG(fatal_error_backtrace));
zval_ptr_dtor(&EG(last_fatal_error_backtrace));
ZVAL_UNDEF(&EG(last_fatal_error_backtrace));

/* Report about uncaught exception in case of fatal errors */
if (EG(exception)) {
Expand All @@ -1490,7 +1490,7 @@ ZEND_API ZEND_COLD void zend_error_zstr_at(
}
}
} else if (EG(fatal_error_backtrace_on) && (type & E_FATAL_ERRORS)) {
zend_fetch_debug_backtrace(&EG(fatal_error_backtrace), 0, EG(exception_ignore_args) ? DEBUG_BACKTRACE_IGNORE_ARGS : 0, 0);
zend_fetch_debug_backtrace(&EG(last_fatal_error_backtrace), 0, EG(exception_ignore_args) ? DEBUG_BACKTRACE_IGNORE_ARGS : 0, 0);
}

zend_observer_error_notify(type, error_filename, error_lineno, message);
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,8 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit
ce_exception = ex->ce;
EG(exception) = NULL;

zval_ptr_dtor(&EG(fatal_error_backtrace));
ZVAL_UNDEF(&EG(fatal_error_backtrace));
zval_ptr_dtor(&EG(last_fatal_error_backtrace));
ZVAL_UNDEF(&EG(last_fatal_error_backtrace));

if (ce_exception == zend_ce_parse_error || ce_exception == zend_ce_compile_error) {
zend_string *message = zval_get_string(GET_PROPERTY(&exception, ZEND_STR_MESSAGE));
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void init_executor(void) /* {{{ */
original_sigsegv_handler = signal(SIGSEGV, zend_handle_sigsegv);
#endif

ZVAL_UNDEF(&EG(fatal_error_backtrace));
ZVAL_UNDEF(&EG(last_fatal_error_backtrace));

EG(symtable_cache_ptr) = EG(symtable_cache);
EG(symtable_cache_limit) = EG(symtable_cache) + SYMTABLE_CACHE_SIZE;
Expand Down Expand Up @@ -309,8 +309,8 @@ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown)
} ZEND_HASH_MAP_FOREACH_END_DEL();
}

zval_ptr_dtor(&EG(fatal_error_backtrace));
ZVAL_UNDEF(&EG(fatal_error_backtrace));
zval_ptr_dtor(&EG(last_fatal_error_backtrace));
ZVAL_UNDEF(&EG(last_fatal_error_backtrace));

/* Release static properties and static variables prior to the final GC run,
* as they may hold GC roots. */
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ struct _zend_executor_globals {
int error_reporting;

bool fatal_error_backtrace_on;
zval fatal_error_backtrace;
zval last_fatal_error_backtrace;

int exit_status;

Expand Down
8 changes: 4 additions & 4 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1437,8 +1437,8 @@ PHP_FUNCTION(error_get_last)
ZVAL_LONG(&tmp, PG(last_error_lineno));
zend_hash_update(Z_ARR_P(return_value), ZSTR_KNOWN(ZEND_STR_LINE), &tmp);

if (!Z_ISUNDEF(EG(fatal_error_backtrace))) {
ZVAL_COPY(&tmp, &EG(fatal_error_backtrace));
if (!Z_ISUNDEF(EG(last_fatal_error_backtrace))) {
ZVAL_COPY(&tmp, &EG(last_fatal_error_backtrace));
zend_hash_update(Z_ARR_P(return_value), ZSTR_KNOWN(ZEND_STR_TRACE), &tmp);
}
}
Expand All @@ -1463,8 +1463,8 @@ PHP_FUNCTION(error_clear_last)
}
}

zval_ptr_dtor(&EG(fatal_error_backtrace));
ZVAL_UNDEF(&EG(fatal_error_backtrace));
zval_ptr_dtor(&EG(last_fatal_error_backtrace));
ZVAL_UNDEF(&EG(last_fatal_error_backtrace));
}
/* }}} */

Expand Down
4 changes: 2 additions & 2 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,8 @@ static ZEND_COLD void php_error_cb(int orig_type, zend_string *error_filename, c
}
}

if (!Z_ISUNDEF(EG(fatal_error_backtrace))) {
backtrace = zend_trace_to_string(Z_ARRVAL(EG(fatal_error_backtrace)), /* include_main */ true);
if (!Z_ISUNDEF(EG(last_fatal_error_backtrace))) {
backtrace = zend_trace_to_string(Z_ARRVAL(EG(last_fatal_error_backtrace)), /* include_main */ true);
}

/* store the error if it has changed */
Expand Down

0 comments on commit 9f29e80

Please sign in to comment.