classification
Title: test_threading is leaking references
Type: Stage: resolved
Components: Tests Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lukasz.langa, pablogsal, vstinner
Priority: high Keywords: patch

Created on 2019-06-01 17:00 by pablogsal, last changed 2019-06-02 21:15 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13729 merged pablogsal, 2019-06-01 19:01
PR 13751 merged pablogsal, 2019-06-02 20:25
Messages (8)
msg344191 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-06-01 17:00
https://buildbot.python.org/all/#/builders/1/builds/601

OK (skipped=1)
.
test_threading leaked [9770, 9772, 9768] references, sum=29310
test_threading leaked [3960, 3961, 3959] memory blocks, sum=11880
2 tests failed again:
    test_asyncio test_threading
msg344195 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-06-01 17:37
❯ ./python -m test test_threading -m test_excepthook_thread_None -R :
Run tests sequentially
0:00:00 load avg: 1.38 [1/1] test_threading
beginning 9 repetitions
123456789
.........
test_threading leaked [364, 364, 364, 364] references, sum=1456
test_threading leaked [164, 164, 164, 164] memory blocks, sum=656
test_threading failed

== Tests result: FAILURE ==

1 test failed:
    test_threading

Total duration: 159 ms
Tests result: FAILURE
msg344197 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-06-01 19:00
The problem here is that there is a reference cycle with threading.ExceptHookArgs but structseq objects are not tracked by the GC.
msg344209 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-06-01 19:28
Łukasz, this PR will fix the x86 Gentoo Refleaks 3.x and friends, so I would recommend landing this before the release.
msg344289 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-06-02 14:45
New changeset 7ffcf848df214135abeea7f6c6faa4135fd0928f by Pablo Galindo in branch 'master':
bpo-37126: Allow structseq objects to be tracked by the GC (GH-13729)
https://github.com/python/cpython/commit/7ffcf848df214135abeea7f6c6faa4135fd0928f
msg344309 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-02 20:23
You forgot to call PyObject_GC_UnTrack() in structseq_dealloc(), no?
msg344310 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-06-02 20:30
> You forgot to call PyObject_GC_UnTrack() in structseq_dealloc(), no?

Yep, thanks for the catch!
msg344320 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-02 21:15
Thanks.

commit 3caf4de6f05f68c3a175f4d8ce870d7a0016622a
Author: Pablo Galindo <Pablogsal@gmail.com>
Date:   Sun Jun 2 21:52:49 2019 +0100

    Call PyObject_GC_UnTrack in structseq dealloc (GH-13751)

--

FYI I also fixed test_threading:

commit cdce0574d03005e27b843fc110c54c99c7a76412
Author: Victor Stinner <vstinner@redhat.com>
Date:   Sun Jun 2 23:08:41 2019 +0200

    bpo-36829: test_threading: Fix a ref cycle (GH-13752)
History
Date User Action Args
2019-06-02 21:15:11vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg344320
2019-06-02 20:30:51pablogsalsetmessages: + msg344310
stage: patch review -> resolved
2019-06-02 20:25:20pablogsalsetstage: resolved -> patch review
pull_requests: + pull_request13632
2019-06-02 20:23:27vstinnersetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg344309
2019-06-02 14:45:33pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-06-02 14:45:18pablogsalsetmessages: + msg344289
2019-06-01 19:28:02pablogsalsetnosy: + lukasz.langa
messages: + msg344209
2019-06-01 19:01:26pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request13613
2019-06-01 19:00:33pablogsalsetmessages: + msg344197
2019-06-01 17:37:26pablogsalsetpriority: normal -> high
2019-06-01 17:37:19pablogsalsetmessages: + msg344195
2019-06-01 17:00:48pablogsalcreate