Skip to content
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

Fix possible crash in dd_patched_zend_call_known_function #2548

Merged
merged 4 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .circleci/continue_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,28 @@ jobs:
path: /tmp/artifacts
- <<: *STEP_GET_TEST_AGENT_RESULTS

test_early_php_81:
working_directory: ~/datadog
machine:
image: ubuntu-2004:2023.04.2
steps:
- restore_cache:
keys:
- source-v1-{{ .Branch }}-{{ .Revision }}
- <<: *STEP_CHECKOUT
- <<: *STEP_ATTACH_WORKSPACE
- run:
command: |
docker run --rm -v $(pwd):/root -i ubuntu:jammy bash -s \<<COMMANDS
set -e
apt-get update -y
DEBIAN_FRONTEND=noninteractive apt-get install -y php8.1 php8.1-dom php-pear
cd /root
php ./build/packages/datadog-setup.php --php-bin all --file $(ls build/packages/dd-library-php-*-x86_64-linux-gnu.tar.gz)
sed -i 's/datadog.trace.request_init_hook/\;datadog.trace.request_init_hook/' /etc/php/8.1/cli/conf.d/98-ddtrace.ini
pecl run-tests --showdiff --ini=" -d datadog.trace.cli_enabled=1 -d ddtrace.request_init_hook=" \$(find tests/ext -type d)
bwoebi marked this conversation as resolved.
Show resolved Hide resolved
COMMANDS

test_arm:
machine:
image: ubuntu-2004:2023.04.2
Expand Down Expand Up @@ -4026,6 +4048,8 @@ workflows:
batch: [ 6, 7, 8, 9, 10 ]
- installer_tests:
requires: [ 'package extension' ]
- test_early_php_81:
requires: [ 'package extension' ]
- placeholder:
requires: [ 'package extension' ]
name: Framework tests
Expand Down
2 changes: 1 addition & 1 deletion ext/ddtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static void dd_patched_zend_call_known_function(

// If current_execute_data is on the stack, move it to the VM stack
zend_execute_data *execute_data = EG(current_execute_data);
if ((uintptr_t)&retval > (uintptr_t)EX(func) && (uintptr_t)&retval - 0xfffff < (uintptr_t)EX(func)) {
if (execute_data && (uintptr_t)&retval > (uintptr_t)EX(func) && (uintptr_t)&retval - 0xfffff < (uintptr_t)EX(func)) {
zend_execute_data *call = zend_vm_stack_push_call_frame_ex(
ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_execute_data), sizeof(zval)) +
ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_op), sizeof(zval)) +
Expand Down
1 change: 1 addition & 0 deletions zend_abstract_interface/hook/hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ static void zai_hook_entries_destroy(zai_hooks_entry *hooks, zend_ulong install_
ZEND_MAP_PTR_INIT(func.common.run_time_cache, hooks->run_time_cache);
#else
ZEND_MAP_PTR_INIT(func.op_array.run_time_cache, hooks->run_time_cache);
func.common.scope = NULL; // attributes are checked on PHP 8.0, 8.1
#endif
zai_hook_on_update(&func, true, &zai_hook_last_observer);
}
Expand Down
Loading