Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.10] gh-96819: multiprocessing.resource_tracker: check if length of pipe write <= 512 (GH-96890)#97746

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

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletionsLib/multiprocessing/resource_tracker.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -161,10 +161,10 @@ def unregister(self, name, rtype):
def _send(self, cmd, name, rtype):
self.ensure_running()
msg = '{0}:{1}:{2}\n'.format(cmd, name, rtype).encode('ascii')
if len(name) > 512:
if len(msg) > 512:
# posix guarantees that writes to a pipe of less than PIPE_BUF
# bytes are atomic, and that PIPE_BUF >= 512
raise ValueError('name too long')
raise ValueError('msg too long')
nbytes = os.write(self._fd, msg)
assert nbytes == len(msg), "nbytes {0:n} but len(msg) {1:n}".format(
nbytes, len(msg))
Expand Down
8 changes: 8 additions & 0 deletionsLib/test/_test_multiprocessing.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5377,6 +5377,14 @@ def test_resource_tracker_reused(self):

self.assertTrue(is_resource_tracker_reused)

def test_too_long_name_resource(self):
# gh-96819: Resource names that will make the length of a write to a pipe
# greater than PIPE_BUF are not allowed
rtype = "shared_memory"
too_long_name_resource = "a" * (512 - len(rtype))
with self.assertRaises(ValueError):
resource_tracker.register(too_long_name_resource, rtype)


class TestSimpleQueue(unittest.TestCase):

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Fixed check in :mod:`multiprocessing.resource_tracker` that guarantees that the length of a write to a pipe is not greater than ``PIPE_BUF``.

[8]ページ先頭

©2009-2025 Movatter.jp