Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 668
    • Issues 668
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 15
    • Merge requests 15
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Mercurial Paris conference scheduled ! Main event : 2022-09-22. Call for papers deadline: 2022-06-17.

  • PyPy
  • pypypypy
  • Issues
  • #2810

Closed
Open
Created Apr 26, 2018 by Bitbucket Importer@bitbucket_importerMaintainer

Embedding PyPy + cpyext API calls

Created originally on Bitbucket by benamram (Omer Ben-Amram)

Hi guys,

I've been fiddling around with adding pypy support for the rust 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) 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), all of them yielded the following results:

So something like this works (will exit without crashing):

Screen Shot 2018-04-26 at 13.57.59.png

But importing via regular API would crash, interestingly after printing the zen:

Screen Shot 2018-04-26 at 14.00.51.png

Screen Shot 2018-04-26 at 14.02.22.png

Interestingly, using an API that doesn't allocate anything, such as PyBool_FromLong results in a more verbose crash.

Screen Shot 2018-04-26 at 14.04.20.png

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

Thanks!

Omer

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking