-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
SystemError
from calling __iter__
on a released memoryview
#126341
Comments
IIUC, it's undecided right now about what to do with method thread safety--most methods on objects aren't thread-safe, so you should be using a lock. |
SystemError
from accessing a memoryview
from two threadsSystemError
from calling __iter__
on a released memoryview
It seems to be independent of threads, my bad for not reducing further. The code below reliably causes the av = memoryview(b"something")
av.release()
av.__iter__() |
I'm assuming the segfault is a result of missing thread safety on |
@picnixz Considering your recent ventures with |
I would expect to see something like: CHECK_RELEASED(obj); as the fix. |
Please do so! I'm working on HACL* HMAC now and won't be available for the next few days. (I'll also fix a simple curses issue in a few hours (DONE)). |
Yeah, @sobolevn is right. I'll let someone newer have a chance to contribute since it's a super easy fix :) index d4672e8198..25634f997a 100644
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -3356,6 +3356,7 @@ memory_iter(PyObject *seq)
PyErr_BadInternalCall();
return NULL;
}
+ CHECK_RELEASED(seq);
PyMemoryViewObject *obj = (PyMemoryViewObject *)seq;
int ndims = obj->view.ndim;
if (ndims == 0) { |
Is the segfault something to worry about in other |
Let's deal with the segfault separately. I'm assuming that it's a data race, so we just need to add |
Can I be assigned to this issue? I'm an undergraduate student looking to contribute to my first open source project. |
@ritvikpasham Go for it :) |
@ritvikpasham Are you still working on this? |
Yeah I am! |
Do you need help to write the fix? The fix was provided as a patch in #126341 (comment). |
Sorry for the delay. I'll finish it in the next hour. |
…26759) Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: sobolevn <mail@sobolevn.me>
…w` (pythonGH-126759) (cherry picked from commit a12690e) Co-authored-by: Ritvik Pasham <ritvikpasham@gmail.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: sobolevn <mail@sobolevn.me>
…w` (pythonGH-126759) (cherry picked from commit a12690e) Co-authored-by: Ritvik Pasham <ritvikpasham@gmail.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: sobolevn <mail@sobolevn.me>
…ew` (GH-126759) (#126779) gh-126341: add release check to `__iter__` method of `memoryview` (GH-126759) (cherry picked from commit a12690e) Co-authored-by: Ritvik Pasham <ritvikpasham@gmail.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: sobolevn <mail@sobolevn.me>
…ew` (GH-126759) (#126778) gh-126341: add release check to `__iter__` method of `memoryview` (GH-126759) (cherry picked from commit a12690e) Co-authored-by: Ritvik Pasham <ritvikpasham@gmail.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: sobolevn <mail@sobolevn.me>
Crash report
What happened?
The code below causes a
SystemError
on all tested Python versions in Windows and Linux. In a no-gil debug build of main, besides the expected abort, sometimes a segfault occurs.Common abort:
Rare segfault:
The backtrace for the segfault is:
Found using fusil by @vstinner.
CPython versions tested on:
3.11, 3.12, 3.13, CPython main branch
Operating systems tested on:
Linux, Windows
Output from running 'python -VV' on the command line:
No response
Linked PRs
__iter__
method ofmemoryview
(GH-126759) #126778__iter__
method ofmemoryview
(GH-126759) #126779The text was updated successfully, but these errors were encountered: