keyongtech


  keyongtech > python > 04/2009

 #1  
04-23-09, 03:06 PM
Hugues Salamin
Hello,

The following code will crash with a segfault when compiled using cython (v0.11)

def func():
for (a, b) ,c ,d in zip(zip(range(3), range(3)), range(3), range(3)):
print a, b
print c
print d # This line segfault

Compilation is done using distutils.

If the module is imported in python and func is called, I got a segmentation
fault at the line "print d".

I investigated the error with valgrind and gdb but I still have no clue what is
going on.

I'm on Ubuntu 8.04, Kernel 2.6.24-22-generic

Thanks
 #2  
04-23-09, 08:56 PM
Aahz
In article <mailman.4434.1240496587.11746.python-list>,
Hugues Salamin <hugues.salamin> wrote:
>
>The following code will crash with a segfault when compiled using
>cython (v0.11)
>
>def func():
> for (a, b) ,c ,d in zip(zip(range(3), range(3)), range(3), range(3)):
> print a, b
> print c
> print d # This line segfault


Does this crash if you unpack the a,b tuple inside the loop?
 #3  
04-23-09, 09:39 PM
Stefan Behnel
Hugues Salamin wrote:
> The following code will crash with a segfault when compiled using cython (v0.11)
>
> def func():
> for (a, b) ,c ,d in zip(zip(range(3), range(3)), range(3), range(3)):
> print a, b
> print c
> print d # This line segfault
>
> Compilation is done using distutils.
>
> If the module is imported in python and func is called, I got a segmentation
> fault at the line "print d".


Yes, this works for me in the latest (unstable) developer branch, but fails
in the release branch:

$ cd cython-unstable
$ cat rangeloop.pyx
def func():
for (a, b) ,c ,d in zip(zip(range(3), range(3)), range(3), range(3)):
print a, b
print c
print d # This line segfault

$ python2.6 -c 'import pyximport; pyximport.install(); \
import rangeloop; rangeloop.func()'
0 0
0
0
1 1
1
1
2 2
2
2

$ cd ../cython-release
$ python2.6 -c 'import pyximport; pyximport.install(); \
import rangeloop; rangeloop.func()'
0 0
0
Segmentation fault

Not sure why. I'm moving this to the Cython mailing list, we should be able
to help you there.

Stefan
Similar Threads
C++0x: Tuple unpacking as arguments in function call

Hello, I'd like to know what is the way to unpack a tuple into function call arguments. I've seen in an old article for the standard that a function called std::apply( Func,...

Tuple parameter unpacking in 3.x

-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9...

problems when unpacking tuple ...

Dear all, Maybe I stared on the monitor for too long, because I cannot find the bug ... My script "transition_filter.py" starts with the following lines: import sys for...

Tuple Unpacking in raise

Hello All, Is this a bug? Why is this tuple getting unpacked by raise? Am I missing some subtle logic? Why does print not work the same way as raise? Both are statements....

Idiom for default values when unpacking a tuple

I'm trying to manage some configuration data in a list of tuples, and I unpack the values with something like this: configList =...


All times are GMT. The time now is 01:28 AM. | Privacy Policy