-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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 :) |
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
The text was updated successfully, but these errors were encountered: