Menu

#29 Segmentation fault in latest CSV

closed-fixed
nobody
5
2004-01-14
2004-01-14
Anonymous
No

#!/usr/bin/env python
#
if 1:
try :
import psyco
from psyco.classes import *
except: pass

class Aclass:
def __init__(self, maxdepth, maxsolution):
self.maxdepth=maxdepth
self.maxsolution=maxsolution
def print_solution_OK(self):
global t0,solution_number
t1=time.time()
solution_number += 1
print "%4d secs %10.4f global %8.4f" % \

(solution_number,t1-t0,t1-T0)
t0=time.time()
def print_solution_BUGGY(self):
global t0,t1,solution_number
t1=time.time()
solution_number += 1
print "%4d secs %10.4f global %8.4f" % \

(solution_number,t1-t0,t1-T0)
t0=time.time()
def recursive_loop(self, depth=0):
while self.maxsolution > solution_number:
if depth == self.maxdepth:
self.print_solution()
else:
self.recursive_loop(depth+1)

import time

T0=t0=time.time()
t1=None
solution_number=0

a=Aclass(maxdepth=2, maxsolution=3)
a.print_solution=a.print_solution_OK
a.recursive_loop()

print

T0=t0=time.time()
t1=None
solution_number=0

a=Aclass(maxdepth=2, maxsolution=3)
a.print_solution=a.print_solution_BUGGY
a.recursive_loop()

"""
output:

Python 2.3.3 (#1, Dec 20 2003, 21:35:49)
[GCC 3.2.3] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import psyco
>>> psyco._psyco.PROCESSOR
'i386'
>>> psyco._psyco.PSYVER
16908448
>>> psyco._psyco.PYVER
33752048
>>> import trigger_bug
1 secs 0.0005 global 0.0005
2 secs 0.0001 global 0.0010
3 secs 0.0000 global 0.0030

1 secs 0.0001 global 0.0001
2 secs 0.0000 global 0.0024
1074098911 secs 0.0000 global 0.0047
Segmentation fault
"""

my compilers are:
gcc -v
Reading specs from
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/specs
Configured with: ../gcc-3.2.3/configure --prefix=/usr
--enable-shared --enable-threads=posix
--enable-__cxa_atexit --disable-checking --with-gnu-ld
--verbose --target=i486-slackware-linux
--host=i486-slackware-linux
Thread model: posix
gcc version 3.2.3

same result in another pc with another version of compiler:
gcc -v
Reading specs from
/usr/lib/gcc-lib/i386-slackware-linux/2.95.3/specs
gcc version 2.95.3 20010315 (release)

Great appreciations for your work !
Sorry for my poor english.

pierpaolo.paolucci@tiscali.it

Discussion

  • Armin Rigo

    Armin Rigo - 2004-01-14

    Logged In: YES
    user_id=4771

    Bug found. It is related to the use of global variables, in
    a subtle way. I made a change recently to spare some
    memory, and I thought it was safe, but it wasn't.

    Fixed in CVS.

     
  • Armin Rigo

    Armin Rigo - 2004-01-14
    • status: open --> closed
     
  • Armin Rigo

    Armin Rigo - 2004-01-14
    • status: closed --> closed-fixed
     

Log in to post a comment.