Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG?] Investigate shared ABI and module state #6613

Open
da-woods opened this issue Jan 12, 2025 · 2 comments
Open

[BUG?] Investigate shared ABI and module state #6613

da-woods opened this issue Jan 12, 2025 · 2 comments

Comments

@da-woods
Copy link
Contributor

Describe your issue

  1. Do we need to add CYTHON_USE_MODULE_STATE to the CYTHON_ABI suffix? I think it might be OK without but there's the potential to go wrong.
  2. Is there a lifetime issue? In principle modules can now be unloaded (although in practice I don't think our reference counting is accurate enough for this to happen...). If we store CyFunction in our shared ABI based on loading it from module a, and then unload module a does this cause a problem? I think it might.
  3. __Pyx_Coroutine_get_frame will always get the globals from whichever module added it to the shared ABI.

I think this is all mostly a theoretical problem, but it's all a bit dubious.

@da-woods
Copy link
Contributor Author

For point 2 - I think we need to disable internal type-checks with CYTHON_USE_MODULE_STATE. i.e. it's fine for other utility code to check if something is a CyFunction, but it's not fine for CyFunctions to check if something is a CyFunction (although for CyFunction specifically there might be a way of doing it).

I think that mainly affects Coroutines and related types. I think these checks are only an optimization though so they're OK to drop.

@da-woods
Copy link
Contributor Author

I'm also not convinced __Pyx_Coroutine_Check and __Pyx_Coroutine_CheckExact are used correctly in all cases even without module state. They're mostly just used for optimization (where it doesn't really matter if it misses) but there's a few cases where it affects behaviour. Can't see an obvious way around that though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant