[issue23643] Segmentation Fault with Large Simple Function

2015-03-13 Thread Ned Deily

Ned Deily added the comment:

(Closed by submitter.)

--
nosy: +ned.deily
resolution:  - duplicate
stage:  - resolved
superseder:  - stack overflow evaluating eval(() * 3)

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23643
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23643] Segmentation Fault with Large Simple Function

2015-03-13 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
nosy: +brett.cannon

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23643
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23643] Segmentation Fault with Large Simple Function

2015-03-12 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

So the recursion crash was fixed in python3,
but it's still one of the limits of the Python AST compiler.

I suggest to replace your long expression by a list:
  exprs = [(1-a36)*(a37)*(1-a41), (a22)*(a33)*(1-a23), ...]
  return sum(exprs)

...but this function requires large storage at runtime, on the Python stack, 
and for the list.
Maybe better:
  loopcount = 0
  loopcount += (1-a36)*(a37)*(1-a41)
  ...
  return loopcount

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23643
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23643] Segmentation Fault with Large Simple Function

2015-03-11 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy:  -ned.deily

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23643
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23643] Segmentation Fault with Large Simple Function

2015-03-11 Thread Ned Deily

Ned Deily added the comment:

Isn't this a duplicate of Issue5765 and Issue11383?

--
nosy:  -ronaldoussoren

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23643
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23643] Segmentation Fault with Large Simple Function

2015-03-11 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
components:  -Macintosh

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23643
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23643] Segmentation Fault with Large Simple Function

2015-03-11 Thread Michael Klein

New submission from Michael Klein:

I have gotten Segmentation Fault: 11 with the newest version of Python 2.7 
and nothing but standard functions. The program is of the following form 
(attached to this email):

def loopcountaux(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, 
a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, 
a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43):

loopcount = ((1-a36)*(a37)*(1-a41)) + ((a22)*(a33)*(1-a23)) + 
((a27)*(a34)*(1-a28)) + ((a38)*(a43)*(1-a39)) + 
((a40)*(a42)*(1-a41))+((1-a22)*(1-a33)*(a23)) + ((1-a27)*(1-a34)*(a28)) + 
((1-a38)*(1-a43)*(a39)) + ((1-a40)*(1-a42)*(a41)) + ((a36)*(1-a37)*(a41))
return loopcount

print 
loopcountaux(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)

The only difference between this and the file which causes the fault is the 
number of formulas added to the line where loopcount is defined (74858 more 
of a similar kind). Note that this program finds the number of boolean formulas 
from a given set which are true for given variables a1, a2,... For example, 
((1-a36)*(a37)*(1-a41)) is effectively the same as (not a36) and (a37) and 
(not a41).

If this example makes debugging particularly difficult, I can try to find a 
less complex example, though this example is just long enough to cause a 
segfault (with one less statement it runs well).

Thank you for your time.

The OSX error report is as follows:

Process:   Python [8151]
Path:  
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier:Python
Version:   2.7.9 (2.7.9)
Code Type: X86-64 (Native)
Parent Process:bash [3554]
Responsible:   Terminal [599]
User ID:   501

Date/Time: 2015-03-11 12:21:52.952 -0400
OS Version:Mac OS X 10.10.2 (14C109)
Report Version:11
Anonymous UUID:49801587-229C-BA4D-0630-D2490825F5C7

Sleep/Wake UUID:   44D3FBEF-DC64-44CA-A10A-70E9E16AE5C2

Time Awake Since Boot: 16 seconds
Time Since Wake:   17000 seconds

Crashed Thread:0  Dispatch queue: com.apple.main-thread

Exception Type:EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:   KERN_PROTECTION_FAILURE at 0x7fff5f38

VM Regions Near 0x7fff5f38:
MALLOC_SMALL   00014e80-00015100 [ 40.0M] rw-/rwx 
SM=PRV  
-- STACK GUARD7fff5bc0-7fff5f40 [ 56.0M] ---/rwx 
SM=NUL  stack guard for thread 0
Stack  7fff5f40-7fff5fc0 [ 8192K] rw-/rwx 
SM=COW  thread 0

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   org.python.python   0x00010005d734 
PyObject_RichCompareBool + 4
1   org.python.python   0x000100070f38 tuplerichcompare + 
152
2   org.python.python   0x00010005cbf9 PyObject_RichCompare 
+ 201
3   org.python.python   0x00010005d760 
PyObject_RichCompareBool + 48
4   org.python.python   0x000100052ebd lookdict + 397
5   org.python.python   0x000100054900 PyDict_GetItem + 112
6   org.python.python   0x0001000c63a5 compiler_add_o + 277
7   org.python.python   0x0001000c9348 compiler_visit_expr 
+ 840
8   org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
9   org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
10  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
11  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
12  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
13  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
14  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
15  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
16  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
17  org.python.python   0x0001000c9bc0 compiler_visit_expr 
+ 3008
18  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
19  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
20  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
21  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
22  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
23  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
24  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
25  org.python.python   0x0001000c9bac compiler_visit_expr 
+ 2988
26  

[issue23643] Segmentation Fault with Large Simple Function

2015-03-11 Thread Michael Klein

Changes by Michael Klein michael14...@gmail.com:


--
type:  - crash

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23643
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23643] Segmentation Fault with Large Simple Function

2015-03-11 Thread Michael Klein

Michael Klein added the comment:

I found a simpler one, like Amaury's eval(+1 * 748580):

def f(x): 
y = x+x+x+x+x
return y
print f(0)

(Except there are 74875 x+'s. This is exactly enough for a segfault, one less 
runs fine.)

I've tried something like:

 loopcount = 0
  loopcount += (1-a36)*(a37)*(1-a41)
  ...
  return loopcount

It works, but it's still pretty slow. (At least it doesn't crash.) I tried 
converting to C with Cython, but it's too big to be processed in a reasonable 
amount of time, but this is irrelevant to the bug.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23643
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23643] Segmentation Fault with Large Simple Function

2015-03-11 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

Probably a stack overflow, when the AST is too deep:
eval(+1 * 748580) also crashed for me

--
nosy: +amaury.forgeotdarc

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23643
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23643] Segmentation Fault with Large Simple Function

2015-03-11 Thread SilentGhost

SilentGhost added the comment:

This seems to work on linux (returning 0), but fails on 3.4 with RuntimeError: 
maximum recursion depth exceeded during compilation. I wonder if the two are 
related.

--
nosy: +SilentGhost

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23643
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23643] Segmentation Fault with Large Simple Function

2015-03-11 Thread Michael Klein

Changes by Michael Klein michael14...@gmail.com:


--
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23643
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com