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.

Author xtreak
Recipients pablogsal, rhettinger, xtreak
Date 2019-02-10.19:08:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1549825733.5.0.0745476001214.issue35959@roundup.psfhosted.org>
In-reply-to
Content
math.prod introduced with issue35606 seems to segfault when zero is present on some cases like start or middle of the iterable. I couldn't find the exact cause of this. This also occurs in optimized builds.

# Python information built with ./configure && make

➜  cpython git:(master) ./python.exe
Python 3.8.0a1+ (heads/master:8a03ff2ff4, Feb 11 2019, 00:13:49)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

# Segfaults with range(10), [0, 1, 2, 3] and [1, 0, 2, 3]

➜  cpython git:(master) ./python.exe -X faulthandler -c 'import math; print(math.prod(range(10)))'
Fatal Python error: Floating point exception

Current thread 0x00007fff7939f300 (most recent call first):
  File "<string>", line 1 in <module>
[1]    40465 floating point exception  ./python.exe -X faulthandler -c 'import math; print(math.prod(range(10)))'

➜  cpython git:(master) ./python.exe -X faulthandler -c 'import math; print(math.prod([0, 1, 2, 3]))'
Fatal Python error: Floating point exception

Current thread 0x00007fff7939f300 (most recent call first):
  File "<string>", line 1 in <module>
[1]    40414 floating point exception  ./python.exe -X faulthandler -c 'import math; print(math.prod([0, 1, 2, 3]))'
➜  cpython git:(master) ./python.exe -X faulthandler -c 'import math; print(math.prod([1, 0, 2, 3]))'
Fatal Python error: Floating point exception

Current thread 0x00007fff7939f300 (most recent call first):
  File "<string>", line 1 in <module>
[1]    40425 floating point exception  ./python.exe -X faulthandler -c 'import math; print(math.prod([1, 0, 2, 3]))'


# No segfault when zero is at the end and floats seem to work fine.

➜  cpython git:(master) ./python.exe -X faulthandler -c 'import math; print(math.prod([1, 2, 3, 0]))'
0
➜  cpython git:(master) ./python.exe -c 'import math; print(math.prod(map(float, range(10))))'
0.0
History
Date User Action Args
2019-02-10 19:08:57xtreaksetrecipients: + xtreak, rhettinger, pablogsal
2019-02-10 19:08:53xtreaksetmessageid: <1549825733.5.0.0745476001214.issue35959@roundup.psfhosted.org>
2019-02-10 19:08:53xtreaklinkissue35959 messages
2019-02-10 19:08:53xtreakcreate