Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83684
| Path | csiph.com!usenet.pasdenom.info!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'static': 0.04; 'interpreter': 0.05; 'discard': 0.07; 'memory.': 0.07; 'python3': 0.07; 'bug.': 0.09; 'overflow': 0.09; 'overwrite': 0.09; 'returns,': 0.09; 'stack,': 0.09; 'windows,': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'def': 0.12; 'jan': 0.12; 'wrote': 0.14; '(code': 0.16; '10:00': 0.16; '1:13': 0.16; 'does,': 0.16; 'expression,': 0.16; 'fiddle': 0.16; 'foot': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'likewise': 0.16; 'limit,': 0.16; 'loop.': 0.16; 'none.': 0.16; 'reedy': 0.16; 'segfault': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'trying': 0.19; 'stack': 0.19; '>>>': 0.22; 'code,': 0.22; 'memory': 0.22; 'import': 0.22; 'coding': 0.22; 'otherwise,': 0.22; 'saying': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; "shouldn't": 0.24; 'cc:2**0': 0.24; 'tracker': 0.26; 'header:In- Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; "i'm": 0.30; 'code': 0.31; '13,': 0.31; 'away.': 0.31; 'boundary': 0.31; 'crash': 0.31; 'ctypes': 0.31; 'fault': 0.31; 'shoot': 0.31; 'yes.': 0.31; 'skip:c 30': 0.32; 'linux': 0.33; 'url:python': 0.33; 'guess': 0.33; 'actual': 0.34; 'comment': 0.34; "i'd": 0.34; 'could': 0.34; "can't": 0.35; 'problem.': 0.35; 'beyond': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'really': 0.36; 'data,': 0.36; 'error.': 0.37; 'expected': 0.38; 'whatever': 0.38; 'issue': 0.38; 'pm,': 0.38; 'that,': 0.38; 'though,': 0.39; 'sure': 0.39; 'above,': 0.60; 'then,': 0.60; 'simple': 0.61; "you're": 0.61; 'back': 0.62; 'skip:n 10': 0.64; 'more': 0.64; 'limit': 0.70; 'to,': 0.72; 'yourself': 0.78; 'truth': 0.81; '2014,': 0.84; '2015': 0.84; 'url:comments': 0.91; 'to:none': 0.92; 'have.': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=l+Zx5fGhphYH2TK+qKqnZBbOMXQNLOjnLwa+8hwA5JI=; b=yCKiWBclcJRbnoXEGK0T2gdevNNUyQY0i+LZRaZJGa3RUb6eJbjehNjp+NRXVV/apG Kn3LL6Lz77pbdllND2NGRiv6vdLuf0c+K6fh7EY5aG0mCpd8HFVG8H73MbXgmbzxhnxv xwclmoQXQ/FIVwN62ay4gBRTxLhkLzcUlSUspeo45YK+RbQT0uu2nL4fOm+JuD7XQVN/ t6abpR4rkfhhQ2znPaOt8sKNeA3llQP/t/jydSkkkQpOdI9ojgecoTNdcYMPS/NSwBd1 3gi5LinBSoMCA9kbPIFx1BIeVt2d2htNuG2ckAUG3qdAK4mOsf+DjTFFLE+27jhLck3Q tJfg== |
| MIME-Version | 1.0 |
| X-Received | by 10.107.134.39 with SMTP id i39mr32549064iod.53.1421148006956; Tue, 13 Jan 2015 03:20:06 -0800 (PST) |
| In-Reply-To | <87lhl7c5dt.fsf@elektro.pacujo.net> |
| References | <54ABB88A.7070504@r3dsolutions.com> <54ABC52A.1050507@davea.name> <54ABE383.3020801@r3dsolutions.com> <CAPTjJmpktyHfghEr+cjPrhso7JgB4VfS4=5Gdi95gT0aFbSYGA@mail.gmail.com> <54AC97D9.4010504@r3dsolutions.com> <CAPTjJmooTK_+HVoeyeSrqBHN1=YjRYQ2kfDyQtL9JoA9SbTqsQ@mail.gmail.com> <54ACAA04.60801@r3dsolutions.com> <54ADC99F.3020405@stoneleaf.us> <54B44A64.7010105@r3dsolutions.com> <CAPTjJmr0Bqcyj=VBADVSthSZ+pYMXQeNC-j8qLC2xHAVLUmcgA@mail.gmail.com> <mailman.17650.1421114374.18130.python-list@python.org> <54b4aded$0$2738$c3e8da3$76491128@news.astraweb.com> <CAPTjJmq5E+LJ8gjXQa7Sf+smc8ug59YZpofp7PH6WwjL55Gv=Q@mail.gmail.com> <mailman.17669.1421146184.18130.python-list@python.org> <87lhl7c5dt.fsf@elektro.pacujo.net> |
| Date | Tue, 13 Jan 2015 22:20:06 +1100 |
| Subject | Re: Comparisons and sorting of a numeric class.... |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17671.1421148016.18130.python-list@python.org> (permalink) |
| Lines | 57 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1421148016 news.xs4all.nl 2892 [2001:888:2000:d::a6]:43984 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:83684 |
Show key headers only | View raw
On Tue, Jan 13, 2015 at 10:00 PM, Marko Rauhamaa <marko@pacujo.net> wrote: > Terry Reedy <tjreedy@udel.edu>: > >> On 1/13/2015 1:13 AM, Chris Angelico wrote: >>>>>> def f(): sys.setrecursionlimit(sys.getrecursionlimit()+1) or f() >>> ... >>>>>> f() >>> Segmentation fault >>> >>> But otherwise, yes. You shouldn't be able to segfault Python with >>> Python code. >> >> I would have expected an out-of-memory error. If there is not already >> a crash issue on the tracker for this, you could add one. > > Linux grants memory it doesn't have. The truth comes out as a > segmentation fault. Call it modern banking. I'm not sure it's a Linux problem. The same thing happens on Windows, only without the "Segmentation fault" line. The exact behaviour on stack overflow would depend on the layout of memory... back when I wrote real-mode single-segment programs in DOS, the standard layout was PSP, then code, then data, then stack, so overusing the stack would overwrite your static data (and then, if you're really bad, your code as well... things got fun then). My best guess now would be that there's an actual boundary to the stack, and trying to access beyond that triggers an immediate error - "you're not allowed to use that memory". Nothing to do with over-allocating memory. > The code above, though, shouldn't consume memory since it is a simple > tail-recursive loop. Only if the interpreter can optimize it away. Bear in mind that it doesn't _return_ the result of that expression, so it needs to take whatever f() returns, discard it, and return None. But I could have defeated that, if I'd wanted to, by coding it to reduce the recursion limit again after the call - it can't optimize away a non-tail-call. Point is, if you take away the recursion limit, you _can_ crash CPython. Likewise if you fiddle around with ctypes: $ python3 Python 3.5.0a0 (default:1c51f1650c42+, Dec 29 2014, 02:29:06) [GCC 4.7.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import ctypes >>> ctypes.cast(id(1), ctypes.POINTER(ctypes.c_int))[6]=2 >>> 1 Segmentation fault Not a bug. just a gun that you can shoot yourself in the foot with. (Code nicked from http://www.reddit.com/r/Python/comments/2441cv/can_you_change_the_value_of_1/ - from a comment saying "changing 1 this way just destroys everything". Yep, it does, and pretty quckly too.) ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Comparisons and sorting of a numeric class.... Andrew Robinson <andrew3@r3dsolutions.com> - 2015-01-12 17:59 -0800
Re: Comparisons and sorting of a numeric class.... Steven D'Aprano <steve@pearwood.info> - 2015-01-13 05:32 +0000
Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-13 17:13 +1100
Re: Comparisons and sorting of a numeric class.... Terry Reedy <tjreedy@udel.edu> - 2015-01-13 05:49 -0500
Re: Comparisons and sorting of a numeric class.... Marko Rauhamaa <marko@pacujo.net> - 2015-01-13 13:00 +0200
Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-13 22:20 +1100
Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-13 11:56 -0700
Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-14 06:02 +1100
Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-13 21:56 +1100
Re: Comparisons and sorting of a numeric class.... Andrew Robinson <andrew3@r3dsolutions.com> - 2015-01-13 16:12 -0800
Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-14 01:31 -0700
Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-14 22:26 -0700
Re: Comparisons and sorting of a numeric class.... Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-01-16 22:23 +1300
Re: Comparisons and sorting of a numeric class.... Andrew Robinson <andrew3@r3dsolutions.com> - 2015-01-14 23:23 -0800
Re: Comparisons and sorting of a numeric class.... Steven D'Aprano <steve@pearwood.info> - 2015-01-15 08:41 +0000
Re: Comparisons and sorting of a numeric class.... Andrew Robinson <andrew3@r3dsolutions.com> - 2015-01-15 17:45 -0800
Re: Comparisons and sorting of a numeric class.... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-16 18:33 +1100
Re: Comparisons and sorting of a numeric class.... Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-01-17 00:07 +1300
Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-16 03:22 -0800
Re: Comparisons and sorting of a numeric class.... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-17 23:27 +1100
Re: Comparisons and sorting of a numeric class.... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-16 02:27 +0000
Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-15 22:01 -0700
Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-16 17:58 +1100
Re: Comparisons and sorting of a numeric class.... Rob Gaddi <rgaddi@technologyhighland.invalid> - 2015-01-15 09:54 -0800
Re: Comparisons and sorting of a numeric class.... Andrew Robinson <andrew3@r3dsolutions.com> - 2015-01-26 15:47 -0800
Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-26 18:50 -0700
Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-15 10:05 -0700
Re: Comparisons and sorting of a numeric class.... Andrew Robinson <andrew3@r3dsolutions.com> - 2015-01-23 03:46 -0800
Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 07:31 -0800
Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-23 09:50 -0700
Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 09:03 -0800
Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-24 04:23 +1100
Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 09:29 -0800
Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-23 11:04 -0700
Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 19:13 -0800
Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 19:21 -0800
Re: Comparisons and sorting of a numeric class.... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-24 16:01 +1100
Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-24 16:43 +1100
Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 09:22 -0800
Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-24 04:37 +1100
Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 09:45 -0800
Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-24 05:03 +1100
Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-23 11:13 -0700
Re: Comparisons and sorting of a numeric class.... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-24 19:27 +1100
Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-23 22:58 +1100
Re: Comparisons and sorting of a numeric class.... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-23 12:07 +0000
Re: Comparisons and sorting of a numeric class.... Terry Reedy <tjreedy@udel.edu> - 2015-01-23 11:17 -0500
Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-23 11:00 -0700
csiph-web