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

Mem leak in PHP 7.1.* with DYNAMIC_MALLOC_SPRINTF when type IS_OBJECT #81

Open
asgrim opened this issue Jun 8, 2021 · 1 comment
Open
Labels
bug Something isn't working nice to have

Comments

@asgrim
Copy link
Collaborator

asgrim commented Jun 8, 2021

For some reason, there's a memory leak in PHP 7.1.* with the DYNAMIC_MALLOC_SPRINTF macro used in the IS_OBJECT branch of safely_copy_argument_zval_as_scalar. I tried a few things but couldn't get to the bottom of it. As a workaround, for PHP 7.1.* I just return the string (object) rather than the actual object type, but it would be nice if we could get to the bottom of this.

Note: whilst tests only show failures after PHP 7.1.17+ this is because 7.1.16 and below did not have REPORT_EXIT_STATUS=1 as default.

@asgrim asgrim added bug Something isn't working nice to have labels Jun 8, 2021
@asgrim
Copy link
Collaborator Author

asgrim commented Jun 8, 2021

Note, the $client->getRange('foo', 0, 2); causes it to fail in the Predis test, because the argument is an object, so that's a good testcase. Script to reproduce in example.php:

<?php

require "/tmp/scout_predis_test/vendor/autoload.php";

$client = new \Predis\Client();

$client->set('foo', 'bar');
echo $client->getRange('foo', 0, 2);

var_dump(scoutapm_get_calls());

Command to memcheck:

ZEND_DONT_UNLOAD_MODULES=1 USE_ZEND_ALLOC=0 valgrind --leak-check=full /home/james/workspace/php-src-build/bin/php -d zend_extension=`pwd`/modules/scoutapm.so example.php

Or the test suite as a whole:

/home/james/workspace/php-src-build/bin/php run-tests.php -p /home/james/workspace/php-src-build/bin/php -d zend_extension=`pwd`/modules/scoutapm.so -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP" --offline --show-diff --set-timeout 120 -m -q

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working nice to have
Projects
None yet
Development

No branches or pull requests

1 participant