classification
Title: Use after free in ctypes test suite
Type: behavior Stage: patch review
Components: ctypes, Tests Versions: Python 3.8, Python 3.7, Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, belopolsky, blarsen, btharper, gregory.p.smith, meador.inge, twouters
Priority: normal Keywords: patch

Created on 2019-03-10 00:08 by btharper, last changed 2019-09-10 15:20 by twouters.

Files
File name Uploaded Description Edit
asan StringPtrTestCase.txt btharper, 2019-03-10 00:08 Stack trace of failure
Pull Requests
URL Status Linked Edit
PR 12257 merged btharper, 2019-03-10 00:13
Messages (3)
msg337583 - (view) Author: Ben Harper (btharper) * Date: 2019-03-10 00:08
When running the builtin test suite with address sanitizer enabled, one of the ctypes tests causes a use after free demonstrating the danger of using a reference to the inside of a deallocated buffer. This use is detected as an error by the address sanitizer and can be replicated with the following; a stack trace from the resulting failure is attached.

export ASAN_OPTIONS="detect_leaks=0"
make clean
./configure --with-address-sanitizer --with-pydebug
make
./python Lib/ctypes/test/test_stringptr.py StringPtrTestCase -v
msg339258 - (view) Author: Brad Larsen (blarsen) * Date: 2019-03-31 14:01
I was just going to submit a patch for this, then I found this issue.

I can confirm; I see the same use-after-free without the fix.
msg351697 - (view) Author: Thomas Wouters (twouters) * (Python committer) Date: 2019-09-10 15:20
New changeset a9b6033179b64b985394ad351501089a6a94fc9d by T. Wouters (Ben Harper) in branch 'master':
bpo-36253: Remove use after free reference in ctypes test suite (GH-12257)
https://github.com/python/cpython/commit/a9b6033179b64b985394ad351501089a6a94fc9d
History
Date User Action Args
2019-09-10 15:20:18twouterssetnosy: + twouters
messages: + msg351697
2019-03-31 14:01:59blarsensetnosy: + blarsen
messages: + msg339258
2019-03-10 04:36:44xtreaksetnosy: + gregory.p.smith, amaury.forgeotdarc, belopolsky, meador.inge
2019-03-10 00:13:27btharpersetkeywords: + patch
stage: patch review
pull_requests: + pull_request12243
2019-03-10 00:08:40btharpercreate