Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #22257
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ckaynor@zindagigames.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.076 |
| X-Spam-Evidence | '*H*': 0.85; '*S*': 0.00; '>>>>': 0.09; 'sys': 0.09; 'unlikely': 0.09; 'python': 0.11; 'subject:python': 0.12; 'random': 0.13; 'cc:addr:python-list': 0.15; '2.7.2': 0.16; 'compiler,': 0.16; 'exception.': 0.16; 'exceptions': 0.16; 'occur.': 0.16; 'throw': 0.16; 'stack': 0.18; 'def': 0.20; 'trying': 0.20; 'wrote:': 0.21; 'calls.': 0.22; 'header:In-Reply- To:1': 0.22; 'import': 0.24; '>>>': 0.24; 'cc:no real name:2**0': 0.26; '(the': 0.26; 'message-id:@mail.gmail.com': 0.27; 'cc:addr:python.org': 0.27; 'pm,': 0.28; '27,': 0.29; 'os,': 0.29; 'code': 0.29; 'cc:2**0': 0.31; 'maybe': 0.31; 'received:209.85': 0.32; 'received:209.85.212': 0.32; 'received:google.com': 0.32; 'hi,': 0.33; 'skip:s 20': 0.34; 'too': 0.35; 'received:209': 0.35; 'why': 0.36; 'michael': 0.38; 'issue': 0.38; 'your': 0.60; 'mar': 0.61; 'steps': 0.61; 'such': 0.61; 'calls': 0.63; 'between': 0.64; 'results': 0.65; 'numbers': 0.65; 'remove': 0.65; 'vary': 0.66; '2012': 0.69; 'exact': 0.70; 'limit': 0.73; 'generator,': 0.84; 'machine,': 0.84; 'random,': 0.84; 'recursion': 0.84; 'etc),': 0.91; 'received:209.85.212.178': 0.91; 'turning': 0.93 |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding:x-gm-message-state; bh=gqtwVwj8Xd+Bx8hLJRmCltkR1PtxnxgJhMFt+FNXmb8=; b=hEok2UIQsVAYqPAJe4sY9b4fEF/0hWLLOba0gY6ETAfi0HGe3OiHR6BsS6loUB/sME Fk9PTqh4ESJvRDood+wLiDLs1mmESQ1HSTGoGpyH7pXsTZm6GkrGGNWdbSd9s7EcVWpn t8Vz5yAhrUOEY0X5TmP/JOLFj0B110abJsqDFmBOxA1qZ5uvbeenWAUTpyMjsXFhTnJI XDsXoEvU9XkCAbdALbplXxY2BMxmvyNCZ3KlFiimYkr/98CR1KIK5xA1zrJqMAb6uG5M 7t8PenCNhzEv2uRBjyo5X6o9HItX+mL2dpxQMAO6quZkCsauBB2y9p/jrN6k6WgKQ8Pl 2gNg== |
| MIME-Version | 1.0 |
| In-Reply-To | <20120327222757.GA22125@terra.cms.at> |
| References | <20120327222757.GA22125@terra.cms.at> |
| From | Chris Kaynor <ckaynor@zindagigames.com> |
| Date | Tue, 27 Mar 2012 15:40:04 -0700 |
| Subject | Re: python segfault |
| To | Michael Poeltl <michael.poeltl@univie.ac.at> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-Gm-Message-State | ALoCoQkcIyWiduQL1JC0GqamMuE1uRuqAIBmEKdQutIPFAnDus+qSungqRhmXH08in3RebafBYK2 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1054.1332888026.3037.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1332888026 news.xs4all.nl 6972 [2001:888:2000:d::a6]:40858 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:22257 |
Show key headers only | View raw
On Tue, Mar 27, 2012 at 3:27 PM, Michael Poeltl <michael.poeltl@univie.ac.at> wrote: > hi, > > can anybody tell why this 'little stupid *thing* of code' let's python-3.2.2, 2.6.X or python 2.7.2 segfault? > >>> def get_steps2(pos=0, steps=0): > ... if steps == 0: > ... pos = random.randint(-1,1) > ... if pos == 0: > ... return steps > ... steps += 2 > ... pos += random.randint(-1,1) > ... return get_steps2(pos,steps) > ... >>>> import random, sys >>>> sys.setrecursionlimit(100000) If you remove this setrecursionlimit, it will throw an exception. The issue is that your code is overflowing the C stack by trying to make too many calls. The Python recursion limit prevents this by turning such cases into Python exceptions prior to the stack overflow. As your recursion is based on a random number generator, all you need is a sequence of random numbers that is unbalanced between -1 and 1 results for 1000-3000 calls (the exact number will vary from os, compiler, maybe machine, etc), which is not too unlikely to occur.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: python segfault Chris Kaynor <ckaynor@zindagigames.com> - 2012-03-27 15:40 -0700
csiph-web