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

Fix refcounting bug in module initialization #317

Merged
merged 2 commits into from
Aug 26, 2024

Conversation

davisagli
Copy link
Member

Fixes #316

PyModule_AddObject steals a reference, so we have to Py_INCREF the values that we are passing to it but also owned by the _zic_module_state.

@davisagli davisagli requested a review from tseaver August 26, 2024 05:32
PyModule_AddObject steals a reference,
so we have to Py_INCREF the values that we are passing to it
but also owned by the _zic_module_state.
Copy link
Member

@tseaver tseaver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find! Ideally we'd use PyModule_AddObjectRef instead, but it isn't available for Python < 3.10.

src/zope/interface/_zope_interface_coptimizations.c Outdated Show resolved Hide resolved
@davisagli davisagli merged commit 9a2d03e into master Aug 26, 2024
54 checks passed
@davisagli davisagli deleted the davisagli-fix-gc-assertion branch August 26, 2024 15:33
@tseaver
Copy link
Member

tseaver commented Aug 26, 2024

@davisagli Are you preparing the 7.0.2 release PR?

@davisagli
Copy link
Member Author

@tseaver Sure, just a minute

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

Successfully merging this pull request may close these issues.

7.0.1: Modules/gcmodule.c:113: gc_decref: Assertion "gc_get_refs(g) > 0" failed: refcount is too small
2 participants