Skip to content

bpo-31516: Skip test_main_thread_during_shutdown() with COUNT_ALLOCS builds #8052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 <zspytz@gmail.com>
@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 <zspytz@gmail.com>
@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 <zspytz@gmail.com>
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 <zspytz@gmail.com>
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