[Cython] except clause on nogil functions

Robert Bradshaw robertwb at math.washington.edu
Sun Aug 21 06:36:26 CEST 2011


On Sat, Aug 20, 2011 at 2:55 AM, mark florisson
<markflorisson88 at gmail.com> wrote:
> On 20 August 2011 00:34, mark florisson <markflorisson88 at gmail.com> wrote:
>> Hey,
>>
>> I think I found a rather serious bug: if an error label is used in a
>> nogil function, it tries to build a traceback. So if the GIL is
>> released you will immediately segfault, and otherwise it will work
>> fine! Here is a snippet:
>>
>> cdef int with_gil_func() except 0 with gil:
>>    raise Exception("error!")
>>
>> cdef int nogil_func() nogil except 0:
>>    with_gil_func()
>>
>> with nogil:
>>    nogil_func()
>>
>>
>> [0] [00:03] ~  ➤ python -c 'import test'
>> [1]    6888 segmentation fault  python -c 'import test'
>>
>> I've tried as far back as 0.12 but all versions down to 0.12 have it.
>>
>> BTW, it's really weird that the except clause on the function has to
>> come after nogil but before with gil, and otherwise it's a syntax
>> error.
>>
>> Should we fix it and do a bugfix release?
>>
>
> Ok I made a pull request for the fix: https://github.com/cython/cython/pull/56

Thanks.

> Considering that it has been around this long and nobody has reported
> it (?), I assume nobody has had a problem with it, so it's perhaps not
> as urgent as I previously stated.

I agree.

> What about the syntax issue though? Should we fix that?

Sure, I don't see any reason the asymmetry of these options.

- Robert


More information about the cython-devel mailing list