New issue 2810: Embedding PyPy + cpyext API calls https://bitbucket.org/pypy/pypy/issues/2810/embedding-pypy-cpyext-api-calls
Omer Ben-Amram: Hi guys, I've been fiddling around with adding pypy support for the rust [PyO3](https://github.com/PyO3/pyo3). I've been quite successful with the original intent of generating PyPy compatible rust extensions! (wrapped as cpython modules) (the modifications are at - [my fork](https://github.com/omerbenamram/pyo3/tree/feature/add-build-pypy-support)) by correctly linking to libpypy, changing the exported names and re implementing some missing macros in rust. However, the other direction (rust code that embeds pypy) - which would try to call cpyext functions directly from rust works for cpython (since PyO3 handles all cpython initialization correctly), but crashes with PyPy. I'm linking my rust library against a debug version of libpypy (5.10, haven't downloaded 6 yet) I've tried several combinations of calls to `rpython_startup_code`, `pypy_setup_home` (as referenced [here](http://doc.pypy.org/en/latest/embedding.html)), all of them yielded the following results: So something like this works (will exit without crashing):  But importing via regular API would crash, interestingly after printing the zen:   Interestingly, using an API that doesn't allocate anything, such as `PyBool_FromLong` results in a more verbose crash.  I'm suspicious that there is some ref counting/GIL management issue that is causing the crashes. Am I missing something here? would it be possible to use the embedding API to call cpyext emulated functions from rust? A minimal code sample to reproduce the situation can be found [here](https://github.com/omerbenamram/pypy_ffi_playground/tree/pypy-embedding-crash) Thanks! Omer _______________________________________________ pypy-issue mailing list pypy-issue@python.org https://mail.python.org/mailman/listinfo/pypy-issue