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

[3.13] gh-77894: Fix a crash when the GC breaks a loop containing a memoryview (GH-123898) #123936

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Sep 11, 2024

Now a memoryview object can only be cleared if there are no buffers
that refer it.
(cherry picked from commit a1dbf2e)

Co-authored-by: Serhiy Storchaka storchaka@gmail.com

…moryview (pythonGH-123898)

Now a memoryview object can only be cleared if there are no buffers
that refer it.
(cherry picked from commit a1dbf2e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
return 0;
self->flags |= _Py_MEMORYVIEW_RELEASED;
assert(self->mbuf->exports > 0);
if (--self->mbuf->exports == 0) {

Choose a reason for hiding this comment

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

Maybe changing if (--self->mbuf->exports == 0) to

self->mbuf->exports -= 1; // or self->mbuf->exports--;
if (self->mbuf->exports == 0)
...

will be more readable, that my idea.

Choose a reason for hiding this comment

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

I personally think that --self->mbuf->exports is a bit confusing.

Copy link
Member

Choose a reason for hiding this comment

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

This was in the old code.

If you want to change this code, create a PR for the main branch. The backported code should not differ from the original code without good reasons.

return 0;
self->flags |= _Py_MEMORYVIEW_RELEASED;
assert(self->mbuf->exports > 0);
if (--self->mbuf->exports == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

This was in the old code.

If you want to change this code, create a PR for the main branch. The backported code should not differ from the original code without good reasons.

@Yhg1s Yhg1s merged commit 4c3d537 into python:3.13 Sep 30, 2024
39 checks passed
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.

4 participants