classification
Title: x86 Gentoo Refleaks 3.x: test_sys_setprofile leaked [1, 1, 1] references, sum=3
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: inada.naoki, jdemeyer, pablogsal, serhiy.storchaka, vstinner, yselivanov
Priority: normal Keywords: patch

Created on 2018-07-22 19:22 by pablogsal, last changed 2018-07-23 21:46 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 8413 merged jdemeyer, 2018-07-23 13:21
PR 8418 merged miss-islington, 2018-07-23 16:41
Messages (8)
msg322162 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2018-07-22 19:22
The x86 Gentoo Refleaks 3.x report that test_sys_setprofile is potentially leaking referenecs:

https://buildbot.python.org/all/#/builders/1/builds/292

----------------------------------------------------------------------
Ran 21 tests in 0.007s
OK
.
test_sys_setprofile leaked [1, 1, 1] references, sum=3
1 test failed again:
    test_sys_setprofile
== Tests result: FAILURE then FAILURE ==
408 tests OK.
10 slowest tests:
- test_asyncio: 28 min 19 sec
- test_concurrent_futures: 23 min 10 sec
- test_multiprocessing_spawn: 22 min 1 sec
- test_multiprocessing_forkserver: 11 min 24 sec
- test_multiprocessing_fork: 8 min 35 sec
- test_lib2to3: 6 min 39 sec
- test_zipfile: 6 min 21 sec
- test_decimal: 6 min 18 sec
- test_io: 5 min 44 sec
- test_gdb: 5 min 39 sec
1 test failed:
    test_sys_setprofile
8 tests skipped:
    test_devpoll test_kqueue test_msilib test_startfile
    test_winconsoleio test_winreg test_winsound test_zipfile64
1 re-run test:
    test_sys_setprofile
Total duration: 2 hour 10 min
Tests result: FAILURE then FAILURE
msg322163 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2018-07-22 19:23
Same error in the x86 Gentoo Refleaks 3.7 buildbot:

https://buildbot.python.org/all/#/builders/114/builds/174
msg322196 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-23 11:22
I'm able to reproduce the issue on master:

vstinner@apu$ ./python -m test -R 3:3 test_sys_setprofile -m test.test_sys_setprofile.ProfileSimulatorTestCase.test_unbound_method_invalid_args
Run tests sequentially
0:00:00 load avg: 0.82 [1/1] test_sys_setprofile
beginning 6 repetitions
123456
......
test_sys_setprofile leaked [1, 1, 1] references, sum=3
test_sys_setprofile failed

== Tests result: FAILURE ==

1 test failed:
    test_sys_setprofile

Total duration: 113 ms
Tests result: FAILURE

The test has been modified recently:

commit 56868f940e0cc0b35d33c0070107ff3bed2d8766
Author: jdemeyer <jdemeyer@cage.ugent.be>
Date:   Sat Jul 21 10:30:59 2018 +0200

    bpo-34126: Fix crashes while profiling invalid calls. (GH-8300)
msg322198 - (view) Author: Jeroen Demeyer (jdemeyer) * Date: 2018-07-23 11:28
Just to avoid duplicate work: I can have a look at this.
msg322218 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-23 13:42
Ok, so it's a real bug, a reference leak, which have been introduced by:

commit 93fac8dd358cd0e85e7b59115db226ce685d3f6f
Author: INADA Naoki <methane@users.noreply.github.com>
Date:   Tue Mar 7 14:24:37 2017 +0900

    bpo-29676: fix lsprof can't profile C method call. (GH523)
    
    When LOAD_METHOD is used for calling C mehtod, PyMethodDescrObject
    was passed to profilefunc from 5566bbb.
    But lsprof traces only PyCFunctionObject. Additionally, there can be
    some third party extension which assumes passed arg is
    PyCFunctionObject without calling PyCFunction_Check().
    
    So make PyCFunctionObject from PyMethodDescrObject when
    tstate->c_profilefunc is set.
msg322232 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-23 16:41
New changeset 147d95511f59cfdd2d522f9d736f2335457bae20 by Victor Stinner (jdemeyer) in branch 'master':
bpo-34190: Fix reference leak in call_function() (GH-8413)
https://github.com/python/cpython/commit/147d95511f59cfdd2d522f9d736f2335457bae20
msg322266 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-23 21:45
New changeset 25b87d35675301a929982db6d37836666af4f715 by Victor Stinner (Miss Islington (bot)) in branch '3.7':
bpo-34190: Fix reference leak in call_function() (GH-8413) (GH-8418)
https://github.com/python/cpython/commit/25b87d35675301a929982db6d37836666af4f715
msg322267 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-23 21:46
Thanks Jeroen Demeyer for the good and quick fix! I applied it to 3.7 and master branches.
History
Date User Action Args
2018-07-23 21:46:41vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg322267

stage: patch review -> resolved
2018-07-23 21:45:28vstinnersetmessages: + msg322266
2018-07-23 16:41:34miss-islingtonsetpull_requests: + pull_request7944
2018-07-23 16:41:23vstinnersetmessages: + msg322232
2018-07-23 14:17:29vstinnersetversions: + Python 3.7
2018-07-23 13:43:13vstinnersetnosy: + inada.naoki, yselivanov
2018-07-23 13:42:18vstinnersetmessages: + msg322218
2018-07-23 13:21:31jdemeyersetkeywords: + patch
stage: patch review
pull_requests: + pull_request7939
2018-07-23 11:28:55jdemeyersetmessages: + msg322198
2018-07-23 11:24:05vstinnersetnosy: + serhiy.storchaka, jdemeyer
2018-07-23 11:22:58vstinnersetnosy: + vstinner
messages: + msg322196
2018-07-22 19:23:46pablogsalsetmessages: + msg322163
2018-07-22 19:22:01pablogsalcreate