Skip to content

Conversation

@ZackerySpytz
Copy link
Contributor

@ZackerySpytz ZackerySpytz commented Jul 2, 2018

test_main_thread_during_shutdown() (in test_threading) fails when CPython is built with COUNT_ALLOCS. This test should have the requires_type_collecting decorator.

https://bugs.python.org/issue31516

@pitrou
Copy link
Member

pitrou commented Jul 2, 2018

i'm curious, how does the test fail and why?

@pablogsal
Copy link
Member

pablogsal commented Jul 2, 2018

@pitrou I can reproduce it with the current master with this error:

======================================================================
FAIL: test_main_thread_during_shutdown (test.test_threading.ThreadTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/pablogsal/github/cpython/Lib/test/test_threading.py", line 576, in test_main_thread_during_shutdown
    ["GC: True True True"] * 2)
AssertionError: Lists differ: ['GC: True True True'] != ['GC: True True True', 'GC: True True True']

Second list contains 1 additional elements.
First extra element 1:
'GC: True True True'

- ['GC: True True True']
+ ['GC: True True True', 'GC: True True True']

----------------------------------------------------------------------
Ran 158 tests in 10.726s

FAILED (failures=1, skipped=2)
test test_threading failed
test_threading failed

== Tests result: FAILURE ==

1 test failed:
    test_threading

Total duration: 10 sec 820 ms
Tests result: FAILURE

The missing __del__ invocation corresponds to the x=RefCycle() object. It seems that that the type holds a reference to the object that makes its destructor not to be called at shutdown. Explicit destruction of x makes the test pass as well as commenting the Py_INCREF(tp); in Objects/Object.c:inc_count.

@ZackerySpytz
Copy link
Contributor Author

@pablogsal Based on the precedent set in https://bugs.python.org/issue19527, the proper solution (in this case) is to skip the test with requires_type_collecting (see, for example, test_gc_main_module_at_shutdown() and test_gc_ordinary_module_at_shutdown() in test_gc.py, and test_logging_at_shutdown() in test_logging.py).

@miss-islington
Copy link
Contributor

Thanks @ZackerySpytz for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 12, 2018
…builds. (pythonGH-8052)

(cherry picked from commit 65d2f8c)

Co-authored-by: Zackery Spytz <[email protected]>
@bedevere-bot
Copy link

GH-9813 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 12, 2018
…builds. (pythonGH-8052)

(cherry picked from commit 65d2f8c)

Co-authored-by: Zackery Spytz <[email protected]>
@bedevere-bot
Copy link

GH-9814 is a backport of this pull request to the 3.6 branch.

miss-islington added a commit that referenced this pull request Oct 12, 2018
…builds. (GH-8052)

(cherry picked from commit 65d2f8c)

Co-authored-by: Zackery Spytz <[email protected]>
miss-islington added a commit that referenced this pull request Oct 12, 2018
…builds. (GH-8052)

(cherry picked from commit 65d2f8c)

Co-authored-by: Zackery Spytz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants