You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is another leak and usage of uninitialized 'str' because the following "else if" clause doesn't have a 'return' (probably due to copy-paste from unicode_decode_locale() in 3d4226a).
izbyshev commented on Nov 27, 2018
izbyshevmannequin
Mannequin
More actions
Correction: the fall-through in "else if (res == -3)" clause doesn't cause a memory leak, but still results in usage of uninitialized 'str'.
Oh, I see. unicode_encode_locale() has multiple bugs in the code handling errors :-(
I don't think that my commit 3d4226a introduced the memory leak triggered by test_datetime, it seems older. Python 3.7 also has the bug in unicode_encode_locale(). The memory leak has been introduced by commit 7ed7aea, also written by me :-)
Activity
vstinner commentedon Nov 27, 2018
test_datetime currently leaks memory blocks:
test_datetime leaked [3, 4, 3] memory blocks, sum=10
Attached patch should be added to Lib/test/ to only run a minimum set of tests which reproduce the bug.
vstinner commentedon Nov 27, 2018
C:\vstinner\python\master>python -m test -R 3:20 -u all test_datetime
Running Debug|x64 interpreter...
Run tests sequentially
0:00:00 [1/1] test_datetime
beginning 23 repetitions
12345678901234567890123
.......................
test_datetime leaked [1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] memory blocks, sum=21
test_datetime failed
== Tests result: FAILURE ==
1 test failed:
test_datetime
Total duration: 562 ms
Tests result: FAILURE
[-]test_datetime leaks memory[/-][+]test_datetime leaks memory on Windows[/+]izbyshev commentedon Nov 27, 2018
This is because of a leak of 'wstr' at
cpython/Objects/unicodeobject.c
Line 3476 in 1005c84
There is another leak and usage of uninitialized 'str' because the following "else if" clause doesn't have a 'return' (probably due to copy-paste from unicode_decode_locale() in 3d4226a).
izbyshev commentedon Nov 27, 2018
Correction: the fall-through in "else if (res == -3)" clause doesn't cause a memory leak, but still results in usage of uninitialized 'str'.
vstinner commentedon Nov 28, 2018
Oh, I see. unicode_encode_locale() has multiple bugs in the code handling errors :-(
I don't think that my commit 3d4226a introduced the memory leak triggered by test_datetime, it seems older. Python 3.7 also has the bug in unicode_encode_locale(). The memory leak has been introduced by commit 7ed7aea, also written by me :-)
vstinner commentedon Nov 28, 2018
New changeset bde9d6b by Victor Stinner in branch 'master':
bpo-34523, bpo-35322: Fix unicode_encode_locale() (GH-10759)
bde9d6b
vstinner commentedon Nov 28, 2018
bpo-34482 added the test in test_datetime which triggered the bug.
vstinner commentedon Nov 28, 2018
New changeset 85ab974 by Victor Stinner in branch '3.7':
bpo-34523, bpo-35322: Fix unicode_encode_locale() (GH-10759) (GH-10761)
85ab974
vstinner commentedon Nov 28, 2018
I tested manually that "python -m test test_datetime -R 3:3" pass on 3.7 and master branches.
Note: PyUnicode_DecodeLocale() is still untested, only _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx() are tested.