Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
gh-144281: Fix crash on memoryview slice assignment with shared memory#144284
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Changes fromall commits
4cfbb0a674590696d7a42ad0591cFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4932,6 +4932,15 @@ def test_shared_memory_cleaned_after_process_termination(self): | ||
| "resource_tracker: There appear to be 1 leaked " | ||
| "shared_memory objects to clean up at shutdown", err) | ||
| def test_shared_memory_slice_assignment_no_crash(self): | ||
VanshAgarwal24036 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| from multiprocessing import shared_memory | ||
| shm = shared_memory.SharedMemory(create=True, size=10) | ||
| mv = shm.buf | ||
| shm.close() | ||
| shm.unlink() | ||
| with self.assertRaises((BufferError, ValueError)): | ||
| mv[:5] = b'hello' | ||
| @unittest.skipIf(os.name != "posix", "resource_tracker is posix only") | ||
| @resource_tracker_format_subtests | ||
| def test_shared_memory_untracking(self): | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix a possible interpreter crash during memoryview slice assignment when the | ||
| underlying buffer is backed by shared memory. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2656,6 +2656,11 @@ memory_ass_sub(PyObject *_self, PyObject *key, PyObject *value) | ||
| CHECK_RELEASED_INT(self); | ||
| if (view->buf==NULL) { | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It is not clear this is a necessary or sufficient fix without a valid specific trigger. ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I’ve updated the test that should also make the need for the view->buf NULL check clearer. Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. The issue is moot since this has been closed, but I'm afraid this still wouldn't have been useful. Your fix is unrelated to the test; it passes with or without it. It is good practice to always run your test scripts against affected versions, to confirm it reproduces the bug. Without that you don't know the testworks. Also note the bug in the OP is a | ||
| PyErr_SetString(PyExc_BufferError,"memoryview: underlying buffer is no longer valid"); | ||
| return-1; | ||
| } | ||
| fmt=adjust_fmt(view); | ||
| if (fmt==NULL) | ||
| return-1; | ||
Uh oh!
There was an error while loading.Please reload this page.