Accidentaly missing return type declaration in extern void C function

21 views
Skip to first unread message

Vladimir Bashkardin

unread,
Feb 5, 2016, 2:32:03 AM2/5/16
to cython-users
Hello,

I encountered the following problem recently with Cython 0.23.4.

I have a simple C void function. I declare it in a Cython wrapper file as cdef extern dummy_func(...). Accidentally, I forgot to declare its return type. It turns out, that Cython thinks that the function returns a PyObject pointer in that case. The corresponding Cython wrapper function then segfaults when it tries to decrement a reference to that non-existent object. I attached a simple example that demonstrates that. You can compile it with compile.sh script (tested on Linux only). The crash should be reproducible by running dummy.py script. I tested it with gcc 4.3.4, icc 15.0.1, and icc 16.0.1 on Linux x86_64 platform.

I think that it would be good to have a warning from Cython in such case that it makes an assumption about the function's return type. Right now, -Wextra does not produce any warnings.

Thank you.
cyvoid.tgz

THOTH

unread,
Feb 5, 2016, 2:44:03 PM2/5/16
to cython-users
I can replicate this bug and agree that there is a bug in Cython... but don't know how to fix it though...
Reply all
Reply to author
Forward
0 new messages