python segfault

Discussion in 'Python' started by Michael Poeltl, Mar 27, 2012.

  1. 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)
    >>> for i in range(200):

    .... print ( get_steps2() )
    ....
    4
    0
    8
    0
    0
    0
    2
    2
    166
    2
    0
    0
    16
    4
    2
    16
    0
    0
    10
    70
    152
    50
    58
    0
    6
    0
    0
    0
    2
    8
    0
    Segmentation fault
    ?>

    funny, isn't it?
    I was able to reproduce this segfault on various machines (32bit 64bit), ubuntu, slackware, debian
    python.X segfaults on all of them

    thx
    Michael
    --
    Michael Poeltl
    Computational Materials Physics voice: +43-1-4277-51409
    Univ. Wien, Sensengasse 8/12 fax: +43-1-4277-9514 (or 9513)
    A-1090 Wien, AUSTRIA cmp.mpi.univie.ac.at
    -------------------------------------------------------------------------------
    ubuntu-11.10 | vim-7.3 | python-3.2.2 | mutt-1.5.21 | elinks-0.12
    -------------------------------------------------------------------------------
    Michael Poeltl, Mar 27, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Juho Saarikko
    Replies:
    6
    Views:
    391
    Christophe Cavalaria
    May 18, 2004
  2. Tim Peters
    Replies:
    1
    Views:
    319
    Juho Saarikko
    May 17, 2004
  3. Travis Berg
    Replies:
    3
    Views:
    534
    Greg Chapman
    Feb 21, 2005
  4. Adrian Immler

    Python 2.4 & PostgreSQL 8 segfault

    Adrian Immler, Mar 3, 2005, in forum: Python
    Replies:
    0
    Views:
    368
    Adrian Immler
    Mar 3, 2005
  5. Andrey Vul
    Replies:
    8
    Views:
    673
    Richard Bos
    Jul 30, 2010
Loading...

Share This Page