classification
Title: Crash or freeze trying to execute b'a' * 0xFFFFFFFFFFFFFFF
Type: Stage:
Components: Versions: Python 3.6, Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: martin.panter, pabstersac, terry.reedy
Priority: normal Keywords:

Created on 2016-07-18 05:39 by pabstersac, last changed 2016-07-22 20:47 by terry.reedy.

Messages (3)
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".
History
Date User Action Args
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