classification
Title: tracemalloc crashes with floating point exception when using StringIO
Type: crash Stage:
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Claudiu.Popa, jcea, python-dev, vstinner
Priority: normal Keywords: patch

Created on 2014-06-02 13:52 by Claudiu.Popa, last changed 2014-06-02 23:33 by jcea. This issue is now closed.

Files
File name Uploaded Description Edit
tracemalloc.patch Claudiu.Popa, 2014-06-02 13:52 review
Messages (3)
msg219587 - (view) Author: PCManticore (Claudiu.Popa) * (Python triager) Date: 2014-06-02 13:52
Given the following code, tracemalloc crashes with:
"Floating point exception: 8 (core dumped)"

import tracemalloc
tracemalloc.start(10)
import io
io.StringIO()

The culprit is this line "assert(nelem <= PY_SIZE_MAX / elsize);" from tracemalloc_alloc. elsize is 0 from stringio.c, "self->buf = (Py_UCS4 *)PyMem_Malloc(0);".
The attached patch skips the assert if elsize is 0, but I don't know if this is the right approach.
Thanks!
msg219623 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-06-02 19:41
New changeset d87ede8da3c8 by Victor Stinner in branch '3.4':
Issue #21639: Fix name of _testcapi test functions
http://hg.python.org/cpython/rev/d87ede8da3c8

New changeset 7083634065c9 by Victor Stinner in branch 'default':
(Merge 3.4) Issue #21639: Fix name of _testcapi test functions
http://hg.python.org/cpython/rev/7083634065c9

New changeset 6f362a702242 by Victor Stinner in branch '3.4':
Issue #21639: Add a test to check that PyMem_Malloc(0) with tracemalloc enabled
http://hg.python.org/cpython/rev/6f362a702242

New changeset 1505124c0df4 by Victor Stinner in branch 'default':
Issue #21639: Fix a division by zero in tracemalloc on calloc(0, 0). The
http://hg.python.org/cpython/rev/1505124c0df4
msg219624 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-06-02 19:42
Thanks for the report, it should now be fixed. The crash is a regression introduced by the issue #21233.
History
Date User Action Args
2014-06-02 23:33:48jceasetnosy: + jcea
2014-06-02 19:42:28vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg219624
2014-06-02 19:41:01python-devsetnosy: + python-dev
messages: + msg219623
2014-06-02 13:52:03Claudiu.Popacreate