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.

Title: tracemalloc crashes with floating point exception when using StringIO
Type: crash Stage:
Components: Library (Lib) Versions: Python 3.5
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 2022-04-11 14:58 by admin. This issue is now closed.

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
import io

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.
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

New changeset 7083634065c9 by Victor Stinner in branch 'default':
(Merge 3.4) Issue #21639: Fix name of _testcapi test functions

New changeset 6f362a702242 by Victor Stinner in branch '3.4':
Issue #21639: Add a test to check that PyMem_Malloc(0) with tracemalloc enabled

New changeset 1505124c0df4 by Victor Stinner in branch 'default':
Issue #21639: Fix a division by zero in tracemalloc on calloc(0, 0). The
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.
Date User Action Args
2022-04-11 14:58:04adminsetgithub: 65838
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