Comments (6)
Apart from using a debug PHP build, you'd also have to patch phpunit to not use exit
, otherwise you're not going to get any leak reports.
from ext-ds.
This seems to be working now. I'll create a leak and verify that it fails.
composer memtest
from ext-ds.
Nope.
from ext-ds.
I've disabled the memory test for now to get a passing build.
from ext-ds.
Here is the valgrind report for the most recent build that failed the memory test:
$ composer memtest
> USE_ZEND_ALLOC=0 ZEND_DONT_UNLOAD_MODULES=1 valgrind php ./vendor/bin/phpunit -c ./vendor/php-ds/tests/phpunit.xml
==10874== Memcheck, a memory error detector
==10874== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==10874== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==10874== Command: php ./vendor/bin/phpunit -c ./vendor/php-ds/tests/phpunit.xml
==10874==
==10874==
==10874== HEAP SUMMARY:
==10874== in use at exit: 25,763 bytes in 223 blocks
==10874== total heap usage: 2,610,963 allocs, 2,610,740 frees, 6,700,558,612 bytes allocated
==10874==
==10874== 56 bytes in 1 blocks are definitely lost in loss record 52 of 103
==10874== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10874== by 0x9048CE: zend_objects_new (zend_objects.c:162)
==10874== by 0x8CE90D: _object_and_properties_init (zend_API.c:1301)
==10874== by 0x9631FC: ZEND_NEW_SPEC_VAR_HANDLER (zend_vm_execute.h:15415)
==10874== by 0x90E2CF: execute_ex (zend_vm_execute.h:417)
==10874== by 0x8BBFDB: zend_call_function (zend_execute_API.c:866)
==10874== by 0x70F1EA: zim_reflection_method_invokeArgs (php_reflection.c:3348)
==10874== by 0x956AE6: ZEND_DO_FCALL_SPEC_HANDLER (zend_vm_execute.h:842)
==10874== by 0x90E2CF: execute_ex (zend_vm_execute.h:417)
==10874== by 0x966396: zend_execute (zend_vm_execute.h:458)
==10874== by 0x8CB8C3: zend_execute_scripts (zend.c:1427)
==10874== by 0x85F6F5: php_execute_script (main.c:2494)
==10874==
==10874== 56 bytes in 1 blocks are definitely lost in loss record 53 of 103
==10874== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10874== by 0x8C8FDB: _zval_copy_ctor_func (zend_string.h:121)
==10874== by 0x911812: ZEND_ASSIGN_SPEC_CV_CONST_HANDLER (zend_execute.h:119)
==10874== by 0x90E2CF: execute_ex (zend_vm_execute.h:417)
==10874== by 0x966396: zend_execute (zend_vm_execute.h:458)
==10874== by 0x8CB8C3: zend_execute_scripts (zend.c:1427)
==10874== by 0x85F6F5: php_execute_script (main.c:2494)
==10874== by 0x96810D: do_cli (php_cli.c:974)
==10874== by 0x456EB4: main (php_cli.c:1344)
==10874==
==10874== 64 bytes in 1 blocks are definitely lost in loss record 57 of 103
==10874== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10874== by 0x8A383F: _ecalloc (zend_alloc.c:2541)
==10874== by 0xF2B550F: php_ds_map_create_object_ex (php_map.c:11)
==10874== by 0x8CE8EA: _object_and_properties_init (zend_API.c:1308)
==10874== by 0x963433: ZEND_NEW_SPEC_CONST_HANDLER (zend_vm_execute.h:3342)
==10874== by 0x90E2CF: execute_ex (zend_vm_execute.h:417)
==10874== by 0x8BBFDB: zend_call_function (zend_execute_API.c:866)
==10874== by 0x70F1EA: zim_reflection_method_invokeArgs (php_reflection.c:3348)
==10874== by 0x956AE6: ZEND_DO_FCALL_SPEC_HANDLER (zend_vm_execute.h:842)
==10874== by 0x90E2CF: execute_ex (zend_vm_execute.h:417)
==10874== by 0x966396: zend_execute (zend_vm_execute.h:458)
==10874== by 0x8CB8C3: zend_execute_scripts (zend.c:1427)
==10874==
==10874== 104 bytes in 1 blocks are definitely lost in loss record 68 of 103
==10874== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10874== by 0x9048CE: zend_objects_new (zend_objects.c:162)
==10874== by 0x8CE90D: _object_and_properties_init (zend_API.c:1301)
==10874== by 0x9631FC: ZEND_NEW_SPEC_VAR_HANDLER (zend_vm_execute.h:15415)
==10874== by 0x90E2CF: execute_ex (zend_vm_execute.h:417)
==10874== by 0x966396: zend_execute (zend_vm_execute.h:458)
==10874== by 0x8CB8C3: zend_execute_scripts (zend.c:1427)
==10874== by 0x85F6F5: php_execute_script (main.c:2494)
==10874== by 0x96810D: do_cli (php_cli.c:974)
==10874== by 0x456EB4: main (php_cli.c:1344)
==10874==
==10874== 128 bytes in 2 blocks are definitely lost in loss record 71 of 103
==10874== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10874== by 0x8A383F: _ecalloc (zend_alloc.c:2541)
==10874== by 0xF2B6C6F: php_ds_set_create_object_ex (php_set.c:9)
==10874== by 0x8CE8EA: _object_and_properties_init (zend_API.c:1308)
==10874== by 0x963433: ZEND_NEW_SPEC_CONST_HANDLER (zend_vm_execute.h:3342)
==10874== by 0x90E2CF: execute_ex (zend_vm_execute.h:417)
==10874== by 0x8BBFDB: zend_call_function (zend_execute_API.c:866)
==10874== by 0x70F1EA: zim_reflection_method_invokeArgs (php_reflection.c:3348)
==10874== by 0x956AE6: ZEND_DO_FCALL_SPEC_HANDLER (zend_vm_execute.h:842)
==10874== by 0x90E2CF: execute_ex (zend_vm_execute.h:417)
==10874== by 0x966396: zend_execute (zend_vm_execute.h:458)
==10874== by 0x8CB8C3: zend_execute_scripts (zend.c:1427)
==10874==
==10874== 256 bytes in 4 blocks are definitely lost in loss record 76 of 103
==10874== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10874== by 0x8A383F: _ecalloc (zend_alloc.c:2541)
==10874== by 0xF2B46FF: php_ds_vector_create_object_ex (php_vector.c:9)
==10874== by 0x8CE8EA: _object_and_properties_init (zend_API.c:1308)
==10874== by 0x963433: ZEND_NEW_SPEC_CONST_HANDLER (zend_vm_execute.h:3342)
==10874== by 0x90E2CF: execute_ex (zend_vm_execute.h:417)
==10874== by 0x8BBFDB: zend_call_function (zend_execute_API.c:866)
==10874== by 0x70F1EA: zim_reflection_method_invokeArgs (php_reflection.c:3348)
==10874== by 0x956AE6: ZEND_DO_FCALL_SPEC_HANDLER (zend_vm_execute.h:842)
==10874== by 0x90E2CF: execute_ex (zend_vm_execute.h:417)
==10874== by 0x966396: zend_execute (zend_vm_execute.h:458)
==10874== by 0x8CB8C3: zend_execute_scripts (zend.c:1427)
==10874==
==10874== 464 (56 direct, 408 indirect) bytes in 1 blocks are definitely lost in loss record 87 of 103
==10874== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10874== by 0x8CDDF7: _array_init (zend_API.c:1061)
==10874== by 0x86EC52: php_build_argv (php_variables.c:537)
==10874== by 0x86F5E9: php_hash_environment (php_variables.c:666)
==10874== by 0x85D668: php_request_startup (main.c:1628)
==10874== by 0x967ABE: do_cli (php_cli.c:945)
==10874== by 0x456EB4: main (php_cli.c:1344)
==10874==
==10874== 872 (640 direct, 232 indirect) bytes in 2 blocks are definitely lost in loss record 95 of 103
==10874== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10874== by 0x9048CE: zend_objects_new (zend_objects.c:162)
==10874== by 0x8CE90D: _object_and_properties_init (zend_API.c:1301)
==10874== by 0x963433: ZEND_NEW_SPEC_CONST_HANDLER (zend_vm_execute.h:3342)
==10874== by 0x90E2CF: execute_ex (zend_vm_execute.h:417)
==10874== by 0x966396: zend_execute (zend_vm_execute.h:458)
==10874== by 0x8CB8C3: zend_execute_scripts (zend.c:1427)
==10874== by 0x85F6F5: php_execute_script (main.c:2494)
==10874== by 0x96810D: do_cli (php_cli.c:974)
==10874== by 0x456EB4: main (php_cli.c:1344)
==10874==
==10874== 4,560 (224 direct, 4,336 indirect) bytes in 1 blocks are definitely lost in loss record 102 of 103
==10874== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10874== by 0x8894D0: compile_file (zend_language_scanner.l:596)
==10874== by 0x6EE37D: phar_compile_file (phar.c:3322)
==10874== by 0x8CB85F: zend_execute_scripts (zend.c:1421)
==10874== by 0x85F6F5: php_execute_script (main.c:2494)
==10874== by 0x96810D: do_cli (php_cli.c:974)
==10874== by 0x456EB4: main (php_cli.c:1344)
==10874==
==10874== 5,504 (24 direct, 5,480 indirect) bytes in 1 blocks are definitely lost in loss record 103 of 103
==10874== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10874== by 0x90F98A: ZEND_SEND_REF_SPEC_CV_HANDLER (zend_vm_execute.h:28911)
==10874== by 0x90E2CF: execute_ex (zend_vm_execute.h:417)
==10874== by 0x966396: zend_execute (zend_vm_execute.h:458)
==10874== by 0x8CB8C3: zend_execute_scripts (zend.c:1427)
==10874== by 0x85F6F5: php_execute_script (main.c:2494)
==10874== by 0x96810D: do_cli (php_cli.c:974)
==10874== by 0x456EB4: main (php_cli.c:1344)
==10874==
==10874== LEAK SUMMARY:
==10874== definitely lost: 1,608 bytes in 15 blocks
==10874== indirectly lost: 10,456 bytes in 111 blocks
==10874== possibly lost: 0 bytes in 0 blocks
==10874== still reachable: 13,699 bytes in 97 blocks
==10874== suppressed: 0 bytes in 0 blocks
==10874== Reachable blocks (those to which a pointer was found) are not shown.
==10874== To see them, rerun with: --leak-check=full --show-reachable=yes
==10874==
==10874== For counts of detected and suppressed errors, rerun with: -v
==10874== ERROR SUMMARY: 10 errors from 10 contexts (suppressed: 2 from 2)
from ext-ds.
I've added a new test script: https://github.com/php-ds/extension/blob/master/test.php
Valgrind options: https://github.com/php-ds/extension/blob/master/.valgrindrc
Travis suppression: https://github.com/php-ds/extension/blob/master/.travis.supp
I don't know why valgrind on Travis is reporting that leak when it doesn't come up on either my OS X machine or on a brand new Ubuntu build. ¯_(ツ)_/¯
from ext-ds.
Related Issues (20)
- Segmentation fault when Map is used with IteratorIterator (v1.3.0) HOT 3
- Testing for Equality HOT 4
- . HOT 1
- map method for Set? HOT 3
- PHP 8.1 compatibility HOT 5
- How to make sure extension is used HOT 5
- How to install in PHP8 Docker alpine:version image? HOT 8
- Support php 7.4's `__unserialize` to prepare for PHP 9.0 removing Serializable
- Release supporting PHP 8.1 HOT 11
- Audit and update documentation HOT 1
- ReflectionClass and ReflectionObject not reporting information when using Ds\Map via extension
- Passing array item by reference breaks \DS\Set behaviour HOT 1
- php_ds.dll for PHP 8.2.x on Windows HOT 2
- Pecl install missing php 8.2 HOT 3
- Better Interface Segregation (Future Version?) HOT 3
- Clarify Support for PHP 8.3.x and 9.x? HOT 11
- Segmentation fault merging keys of maps containing maps HOT 7
- DLL missing on PECL for 1.5.0 HOT 3
- Upgrade PECL page to identify homepage HOT 2
- Null coalescing operator on Vector make search failed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ext-ds.