Skip to content

Commit

Permalink
Prevent crash in shutdown if hook was not stored (#2824)
Browse files Browse the repository at this point in the history
This seems to be possible to happen when fatal errors occur beforehand.

This specific fatal error occurred due to a timeout, hence it's not trivially reproducible.

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
  • Loading branch information
bwoebi authored Aug 30, 2024
1 parent d03ef3f commit 8b6e326
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ The default value for datadog.log_backtrace is now set to true, meaning that on
- Use the Windows User ID as sidecar identifier instead of the Session ID Datadog/libdatadog#558
- Fix error check in trampoline.c Datadog/libdatadog#569
- Do not implicitly fall back to spl_autoload() if no autoloader is registered on PHP 7 #2822
- Prevent crash in shutdown if hook was not stored #2824
### Internal
- Send x-datadog-test-session-token metric and send metrics to request-replayer #2802
Expand Down
3 changes: 2 additions & 1 deletion zend_abstract_interface/hook/hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,8 @@ void zai_hook_finish(zend_execute_data *ex, zval *rv, zai_hook_memory_t *memory)
zend_ulong address = zai_hook_frame_address(ex);
zai_hook_table_find(&zai_hook_resolved, address, (void**)&hooks);
zval *hook_zv;
if ((hook_zv = zend_hash_index_find(&hooks->hooks, (zend_ulong) -hook->id))) {
ZEND_ASSERT(CG(unclean_shutdown) || hooks != NULL);
if (hooks && (hook_zv = zend_hash_index_find(&hooks->hooks, (zend_ulong) -hook->id))) {
if (Z_TYPE_INFO_P(hook_zv) == ZAI_IS_SHARED_HOOK_PTR) {
// lookup primary by name
zend_class_entry *ce = NULL;
Expand Down

0 comments on commit 8b6e326

Please sign in to comment.