New submission from David Lukeš:

The following program makes Python 3.4.3 crash with a segmentation fault:

```
#!/usr/bin/env python3

import operator

N = 500000
l = [0]

for i in range(N):
    l = map(operator.add, l, [1])

print(list(l))
```

I suppose the problem is that there are too many nested lazy calls to map, 
which cause a segfault when evaluated. I've played with N and surprisingly, the 
threshold to cause the crash varied slightly (between 130900 and 131000 on my 
machine).

I know that a list-comprehension, which is evaluated straight away, would be 
much more idiomatic for repeated element-wise addition (or numpy arrays for 
that matter, if available). I'm **not advocating this piece of code**, just 
wondering whether there couldn't be a more informative way to make Python bail 
out instead of the segfault? (In my real application, it took me a while to 
figure where the problem was without a stack trace.)

----------
messages: 246567
nosy: David Lukeš
priority: normal
severity: normal
status: open
title: segfault caused by nested calls to map()
type: crash
versions: Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24606>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to