Giter Site home page Giter Site logo

Check for memory leaks in CI about ext-ds HOT 6 CLOSED

php-ds avatar php-ds commented on July 17, 2024
Check for memory leaks in CI

from ext-ds.

Comments (6)

nikic avatar nikic commented on July 17, 2024

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.

rtheunissen avatar rtheunissen commented on July 17, 2024

This seems to be working now. I'll create a leak and verify that it fails.

composer memtest

from ext-ds.

rtheunissen avatar rtheunissen commented on July 17, 2024

Nope.

from ext-ds.

rtheunissen avatar rtheunissen commented on July 17, 2024

I've disabled the memory test for now to get a passing build.

from ext-ds.

rtheunissen avatar rtheunissen commented on July 17, 2024

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.

rtheunissen avatar rtheunissen commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.