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.

classification
Title: Crash or freeze trying to execute b'a' * 0xFFFFFFFFFFFFFFF
Type: Stage: resolved
Components: Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Malloc errors in test_io
View: 5614
Assigned To: Nosy List: iritkatriel, martin.panter, pabstersac, serhiy.storchaka, terry.reedy
Priority: normal Keywords:

Created on 2016-07-18 05:39 by pabstersac, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg270700 - (view) Author: pablo sacristan (pabstersac) Date: 2016-07-18 05:39
There is an integer overflow because python doesn't check the length as it does with bytearray() and it still goes on, so by doing something like:
>>> import array
>>> float(array.array("L",b"a"*0xFFFFFFFFFFFFFFF+100000**8000000000))
It returns:
Python(2179,0x7fff7ad6a000) malloc: *** mach_vm_map(size=1152921504606851072) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

And then it just crashes
Or you can skip the error and just do:
>>> import array
>>> float(array.array("L",b"a"*0xFFFFFFFFFFFFFFF**10000000000**80000000000000000))

That will just make python freeze until you restart it, which is as good as crashed.
The file would be:
import array
float(array.array("L",b"a"*0xFFFFFFFFFFFFFFF**10000000000**80000000000000000))

Hope it helps ;)
msg270745 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-07-18 10:36
Perhaps this is the same as Issue 5614, i.e. the problem lies with OS X rather than Python?
msg271030 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-07-22 20:47
Crash reports should include the minimum code needed to produce the crash.  Adding function calls that never happen because the arguments cannot be computed adds noise that obscures the problem.  Here, b"a"*0xFFFFFFFFFFFFFFF would require more memory that any current computer has.  Float and array are irrelevant.  On Windows, it freezes python.  A MemoryError would be nicer, but this may be "won't fix".
msg396273 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-06-21 17:15
I get a MemoryError on Windows 10:

>>> float(array.array("L",b"a"*0xFFFFFFFFFFFFFFF+100000**8000000000))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
MemoryError
>>>
msg396277 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-06-21 17:37
Concur with Martin. Most likely it is an OS bug, the same as issue5614.
History
Date User Action Args
2022-04-11 14:58:33adminsetgithub: 71734
2021-06-21 17:37:18serhiy.storchakasetstatus: open -> closed

superseder: Malloc errors in test_io

nosy: + serhiy.storchaka
messages: + msg396277
resolution: duplicate
stage: resolved
2021-06-21 17:15:42iritkatrielsetnosy: + iritkatriel
messages: + msg396273
2016-07-22 20:47:35terry.reedysetnosy: + terry.reedy

messages: + msg271030
title: Integer Overflow Crash On float(array.array()) -> Crash or freeze trying to execute b'a' * 0xFFFFFFFFFFFFFFF
2016-07-18 10:36:22martin.pantersetnosy: + martin.panter
messages: + msg270745
2016-07-18 05:39:04pabstersaccreate