Title: test_weakref intermittent test failure on linux
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7
Milestone: Jython 2.7.1
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: jamesmudd, zyasoft
Priority: Keywords:

Created on 2017-03-20.21:39:42 by jamesmudd, last changed 2017-09-05.20:52:30 by zyasoft.

msg11255 (view) Author: James Mudd (jamesmudd) Date: 2017-03-20.21:39:41
I have observed test_weakref fail a few times while running ant regrtest. The output is:

     [exec] test test_weakref failed -- Traceback (most recent call last):
     [exec]   File "/home/james/git/jython/dist/Lib/test/", line 1029, in test_weak_values
     [exec]     self.assertEqual(len(list(dict.iterkeys())), 0,
     [exec] AssertionError: deleting the values did not clear the dictionary

The failure appears to be intermittent, I haven't reproduced it when running the test individually, and I have never observed it on Windows.
msg11258 (view) Author: Jim Baker (zyasoft) Date: 2017-03-21.03:49:33
So our assumption on these sorts of testing bugs is that multiple phases of GC are often required to clear out weak references; and GC in general is never quite as deterministic as we would like for such testing. (CPython's model in contrast does give us deterministic GC, so it's a bit harder to use the same tests. In practice, it would not matter - one should not rely on determinism in GC even in CPython, given the possibility of cycles.) You can see the specific code used in the extra_collect function.

In particular, test_weak_values does not use the extra_collect function; it instead uses gc.collect directly. It would be worthwhile revisiting with extra_collect here to see if it makes a difference.

Note that if the weakref is never collected, that would be a bug!
Date User Action Args
2017-09-05 20:52:30zyasoftsetstatus: pending -> closed
2017-06-21 16:06:12zyasoftsetstatus: open -> pending
resolution: invalid
milestone: Jython 2.7.1
2017-03-21 03:49:33zyasoftsetnosy: + zyasoft
messages: + msg11258
2017-03-20 21:39:42jamesmuddcreate