[Pyrex] Segfaults and leaked exceptions in 0.9.9

Claudio Freire klaussfreire at gmail.com
Wed Jul 31 20:41:41 CEST 2013


On Wed, Jul 31, 2013 at 3:33 PM, Claudio Freire <klaussfreire at gmail.com> wrote:
> This is interestingly new (I think this didn't happen in 0.9.8, but I
> didn't check)
>
> test.pyx:
>
...
> . def bork():
> .     cdef object rv
> .     try:
> .         rv = {}[3]
> .     except:
> .         rv = None
> .     return rv
...

>>>> import lrucache
>>>> lrucache.bork()
>>>> 3
> KeyError: 3

I should mention that, checking the generated C source, the problem
there lies in pyrex not calling PyErr_Clear at the end of the except
block.

Not calling it is safe as long as the exception has been thrown by
pyrex itself, but in this case, it's python that does, so python does
set the thread's exception state, and pyrex fails to clean up.



More information about the Pyrex mailing list