classification
Title: [2.7] valgrind python2 -m test.regrtest test___all__: definitely lost: 324 bytes in 2 blocks
Type: resource usage Stage: resolved
Components: Extension Modules Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: inada.naoki, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2019-06-18 13:05 by vstinner, last changed 2019-06-28 16:16 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 14202 merged vstinner, 2019-06-18 13:08
Messages (5)
msg345985 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-18 13:05
$ ./configure -C --enable-unicode=ucs4 --with-valgrind
$ make
$ valgrind --suppressions=Misc/valgrind-python.supp ./python -m test.regrtest test___all__
(...)
==18497== LEAK SUMMARY:
==18497==    definitely lost: 324 bytes in 2 blocks
==18497==    indirectly lost: 0 bytes in 0 blocks
==18497==      possibly lost: 5,665,418 bytes in 27,453 blocks
==18497==    still reachable: 8,530,840 bytes in 57,856 blocks
==18497==         suppressed: 32 bytes in 1 blocks
==18497== Reachable blocks (those to which a pointer was found) are not shown.
==18497== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==18497== 
==18497== For lists of detected and suppressed errors, rerun with: -s
==18497== ERROR SUMMARY: 4082 errors from 4082 contexts (suppressed: 0 from 0)

I'm concerned by "324 bytes in 2 blocks". Attached PR fix it.

Downstream issue: https://bugzilla.redhat.com/show_bug.cgi?id=1696322


Fixing "definitely lost" false alarm should help to catch real memory leaks.
msg345986 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-18 13:10
The best would be to explicitly release all memory at exit, but I don't think that it's worth it in Python 2.7 since this version is now stable. More work in done in the master branch to cleanup things at exit (ex: bpo-36724).
msg345987 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-18 13:12
> The best would be to explicitly release all memory at exit, but I don't think that it's worth it in Python 2.7 (...)

Python 2.7 "leaks" a lot of memory at exit...

==18497==      possibly lost: 5,665,418 bytes in 27,453 blocks
==18497==    still reachable: 8,530,840 bytes in 57,856 blocks

... but the operating system releases the memory anyway when the process exit. Technically, it's not a major issue unless you embed Python into an application. But again, it's Python 2.7: I suggest to focus efforts in the master branch.
msg346829 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-28 16:13
New changeset 065aff3c518a641e7a734a5b93f9ebed1b405c49 by Victor Stinner in branch '2.7':
[2.7] bpo-37329: valgrind: ignore _PyWarnings_Init false alarms (GH-14202)
https://github.com/python/cpython/commit/065aff3c518a641e7a734a5b93f9ebed1b405c49
msg346830 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-28 16:16
I confirm that my fix works with this manual test. I get "definitely lost: 0 bytes in 0 blocks" as expected:

$ valgrind --suppressions=Misc/valgrind-python.supp ./python -m test.regrtest test___all__
(...)
==23782== LEAK SUMMARY:
==23782==    definitely lost: 0 bytes in 0 blocks
==23782==    indirectly lost: 0 bytes in 0 blocks
==23782==      possibly lost: 17,945,740 bytes in 85,380 blocks
==23782==    still reachable: 283,821 bytes in 475 blocks
==23782==         suppressed: 2,605 bytes in 20 blocks
==23782== Reachable blocks (those to which a pointer was found) are not shown.
History
Date User Action Args
2019-06-28 16:16:40vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg346830

stage: patch review -> resolved
2019-06-28 16:13:36vstinnersetmessages: + msg346829
2019-06-18 13:12:10vstinnersetmessages: + msg345987
2019-06-18 13:10:18vstinnersetnosy: + inada.naoki, serhiy.storchaka
messages: + msg345986
2019-06-18 13:08:52vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request14040
2019-06-18 13:05:21vstinnercreate