This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author npatel
Recipients louielu, npatel, vstinner, zvyn
Date 2017-06-07.20:23:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496867024.11.0.264553423083.issue30542@psf.upfronthosting.co.za>
In-reply-to
Content
I'd like to respectfully disagree with the suggestions/conclusions mentioned here. I'll explain my reasoning and conclusions below.

First the short version - I'm fairly confident the leak actually has to do with: https://github.com/python/cpython/blob/master/Lib/test/test_tools/test_unparse.py#L282


my approach:

It was initially implied that we can begin to pinpoint the leak from within the test_files() method in test_tools.test_unparse.DirectoryTestCase.

I ran the tests using the command:
python_d -m test -R 3:3 test_tools.test_unparse -m test_files

I had test_files() print the files selected in line 282 (and limited sample size to 1).

Result:
(note: i shortened printed pathnames manually after the fact, as it printed the absolute paths)

python_d -m test -R 3:3 test_tools.test_unparse -m test_files
Run tests sequentially
0:00:00 [1/1] test_tools.test_unparse
Testing cpython\Lib\test\test_spwd.py
beginning 6 repetitions
123456
Testing cpython\Lib\copy.py
.Testing cpython\Lib\test\test_isinstance.py
.Testing cpython\Lib\test\test_bytes.py
.Testing cpython\Lib\test\test_csv.py
.Testing cpython\Lib\test\test_dynamic.py
.Testing cpython\Lib\test\test_xml_etree.py
.
test_tools.test_unparse leaked [3, 0, 13] references, sum=16
test_tools.test_unparse leaked [6, 2, 4] memory blocks, sum=12
test_tools.test_unparse failed

1 test failed:
    test_tools.test_unparse

Total duration: 4 sec
Tests result: FAILURE

Then I made a slight modification: I replaced random.sample(names,1) on line 282 with a list containing the absolute paths to each of those files it tested in the run I described above. That means each of those files would be loaded, compiled and their tests run 6 times.

Result:

python_d -m test -R 3:3 test_tools.test_unparse -m test_files
Run tests sequentially
0:00:00 [1/1] test_tools.test_unparse
beginning 6 repetitions
123456
......
1 test OK.

Total duration: 24 sec
Tests result: SUCCESS


Conclusion:
If the same source files are being read, compiled, and their tests run - with different results - then I do not believe the leak can be associated with the self.checkRoundTrip() method or the compile() method


I don't have an in-depth explanation why this is the case. But removing the call to random.sample() fixes the issue, I am reasonably sure of it. 

I presume to say this because I commented out lines 280-282 and instead I made it instead iterate through subsets of size 50 using slicing (so names[:50] etc) in line 284. I went through the entire set of files, 50 at a time. All ran successfully.
History
Date User Action Args
2017-06-07 20:23:44npatelsetrecipients: + npatel, vstinner, zvyn, louielu
2017-06-07 20:23:44npatelsetmessageid: <1496867024.11.0.264553423083.issue30542@psf.upfronthosting.co.za>
2017-06-07 20:23:44npatellinkissue30542 messages
2017-06-07 20:23:43npatelcreate