8000 gh-77894: Fix a crash when the GC breaks a loop containing a memoryview by serhiy-storchaka · Pull Request #123898 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-77894: Fix a crash when the GC breaks a loop containing a memoryview #123898

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

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

serhiy-storchaka
Copy link
Member
@serhiy-storchaka serhiy-storchaka commented Sep 10, 2024

Now a memoryview object can only be cleared if there are no buffers that refer it.

…moryview

Now a memoryview object can only be cleared if there are no buffers
that refer it.
Copy link
Member
@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@vstinner
Copy link
Member

Ah, test_pickle fails:


ERROR: test_non_continuous_buffer (test.test_pickle.PyPicklingErrorTests.test_non_continuous_buffer) (proto=5)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/pickletester.py", line 2330, in test_non_continuous_buffer
    self.dumps(pb, proto)
    ~~~~~~~~~~^^^^^^^^^^^
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_pickle.py", line 66, in dumps
    p.dump(arg)
    ~~~~~~^^^^^
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/pickle.py", line 499, in dump
    self.save(obj)
    ~~~~~~~~~^^^^^
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/pickle.py", line 572, in save
    f(self, obj)  # Call unbound method with explicit self
    ~^^^^^^^^^^^
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/pickle.py", line 896, in save_picklebuffer
    with obj.raw() as m:
         ~~~~~~~^^
BufferError: cannot extract raw buffer from non-contiguous buffer

@serhiy-storchaka serhiy-storchaka merged commit a1dbf2e into python:main Sep 11, 2024
37 checks passed
@miss-islington-app
Copy link

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the memoryview-clear branch September 11, 2024 09:05
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 11, 2024
…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>
@miss-islington-app
Copy link

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker a1dbf2ea69acc6ccee6292709af1dadd55c068be 3.12

@bedevere-app
Copy link
bedevere-app bot commented Sep 11, 2024

GH-123936 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Sep 11, 2024
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Sep 11, 2024
…ng a memoryview (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>
@bedevere-app
Copy link
bedevere-app bot commented Sep 11, 2024

GH-123937 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Sep 11, 2024
serhiy-storchaka added a commit that referenced this pull request Sep 11, 2024
…emoryview (GH-123898) (GH-123937)

Now a memoryview object can only be cleared if there are no buffers
that refer it.
(cherry picked from commit a1dbf2e)
Yhg1s pushed a commit that referenced this pull request Sep 30, 2024
…emoryview (GH-123898) (#123936)

gh-77894: Fix a crash when the GC breaks a loop containing a memoryview (GH-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>
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.

2 participants
0