Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > python segfault

Reply
Thread Tools

python segfault

 
 
Michael Poeltl
Guest
Posts: n/a
 
      03-27-2012
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
-------------------------------------------------------------------------------
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
invoking a segfault within a segfault handler - is this undefinedbehavior? Andrey Vul C Programming 8 07-30-2010 02:14 PM
Python 2.4 & PostgreSQL 8 segfault Adrian Immler Python 0 03-03-2005 02:53 PM
segfault when calling Python from C thread Travis Berg Python 3 02-21-2005 02:13 PM
This program makes Python segfault - no other does Juho Saarikko Python 6 05-18-2004 07:14 PM
RE: This program makes Python segfault - no other does Tim Peters Python 1 05-17-2004 09:33 PM



Advertisments