[pypy-issue] Issue #1865: cffi call keep alive bug (pypy/pypy)

Alex Gaynor issues-reply at bitbucket.org
Thu Sep 11 21:27:18 CEST 2014

New issue 1865: cffi call keep alive bug

Alex Gaynor:

If you have code that's like `lib.some_call({"key": ffi.new("char[]", "abc")})` and multiple threads, sometimes your program will crash.

The reason is that cffi does not correctly keep the `char[]` alive. In `_call()`, `convert_argument_from_object` will convert this to a struct, but then the `dict` is dead, and if it's collected the `char[]` will also be collected because nothing is keeping it alive.

More information about the pypy-issue mailing list