-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Calling ShareableList.count
in threads aborts: Assertion 'self->exports == 0' failed
#127085
Comments
Hi @devdanzin , I'm a newbie of CPython and want to have a try on this issue. Could it be assigned to me?😊 Best Regards, |
@LindaSummer you don't need to be assigned an issue to work on it. If you're interested in this issue, I suggest you read through the code where the crash happens to understand it. If you feel you found something useful, you can post on this issue with your findings. If you find a possible solution, you can open a PR with your fix. |
Hi @JelleZijlstra , Got it! Thanks very much for your warm guidance! 😊 I will try to go through the code and search for the root cause. Best Regards, |
Hi @JelleZijlstra , Here are some updates during these days.
import multiprocessing.shared_memory
from threading import Thread
def test_memoryview_buffer():
import struct
class TA:
data = bytearray("Uq..SeDAmB+EBrkLl.SG.Z+Z.ZdsV..wT+zLxKwdN\b", encoding="utf8")
_fmt = "b"*len(data)
shm = multiprocessing.shared_memory.SharedMemory(create=True, size=struct.calcsize(_fmt))
def __init__(self):
struct.pack_into(self._fmt, self.shm.buf, 0, *self.data)
def count(self, t):
res = 0
for i in range(len(self.data)):
(v,) = struct.unpack_from('b', self.shm.buf, i)
if i == v:
res += 1
return res
obj = TA()
for x in range(2000):
Thread(target=obj.count, args=(1,)).start()
del obj
test_memoryview_buffer()
This should be inside the SharedMemory release function.
I think it should be a race condition issue on the I will try to learn more about the non-gil synchronization logic and try to find the root cause. Please correct me if my analysis has any problems. 😊 Best Regards, |
Add a test skip if multiprocessing isn't available.
…ython#128019) Add a test skip if multiprocessing isn't available.
Crash report
What happened?
It's possible to abort the interpreter by calling
multiprocessing.shared_memory.ShareableList.count
in threads withPYTHON_GIL=0
in a debug build:Result:
Found using fusil by @vstinner.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.14.0a2+ experimental free-threading build (heads/main-dirty:c9b399fbdb0, Nov 19 2024, 20:12:48) [GCC 11.4.0]
Linked PRs
memoryview->exports
race condition. #127412The text was updated successfully, but these errors were encountered: