[Cython] Bug: Returning real value crashes the code, complex value does not

Martin Fiers Martin.Fiers at intec.ugent.be
Tue Mar 26 10:52:02 CET 2013

Dear Cython developers,

I stumbled upon a strange error when using Cython. I made a minimal 
working example, see attachment for the two necessary files. (btw I 
didn't find the e-mail address of Robert Bradshaw so I could not request 
him for an account on the issue tracker. Is it possible to put the bug 
on there?)

To reproduce the bug:
1) Reboot to Windows :) (the bug only appears on Windows)
2) Run compile_bug.py to generate the Cython extension
3) Try to run the my_func_exposed function:

 >>> import complex_double
(does not crash)
 >>> complex_double.my_func_exposed(1,1j)
 >>> complex_double.my_func_exposed(1,1)

If I put a breakpoint in the code with gdb, jump in the code, and leave 
the function again, it does not crash! Also, it is no problem on Linux.

It has to do with the fact that in the first case, a real value was 
used. In the complex-value case, it does not crash. I went through the 
generated cpp file and I don't see any issues there (the reason I use 
cpp is because it's in a big project that needs cpp enabled; it is 
further linked and so on).

gcc version used: 4.6.2 (mingw)
cython version used: 0.18 (I did pip install Cython)
python version used: python 2.7.3 (MSC v.1500 32 bit).

Looking forward to hearing from you!

With kind regards,


ir. Martin Fiers

Photonics Research Group
Universiteit Gent - Ghent University

Sint-Pietersnieuwstraat 41
9000 Gent - Belgium

T + 32 9 264 34 48
E martin.fiers at intec.ugent.be
W www.caphesim.com


-------------- next part --------------
A non-text attachment was scrubbed...
Name: compile_bug.py
Type: text/x-python
Size: 1087 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20130326/a5db4a3e/attachment.py>
-------------- next part --------------
import cython

cdef public double complex my_func(int a, b): 

        return 1;    
        return b;

def my_func_exposed(int a, b):
    return my_func(a,b)

More information about the cython-devel mailing list