Skip to content
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

gh-127586: properly restore blocked signals in resource_tracker.py #127587

Merged
merged 9 commits into from
Dec 15, 2024

Conversation

stephen-hansen
Copy link
Contributor

@stephen-hansen stephen-hansen commented Dec 4, 2024

Closes #127586. Instead of using SIG_UNBLOCK to undo the blocked "ignored signals" by resource_manager when creating a child process, we instead will save the blocked signal mask as it was prior to the call to SIG_BLOCK and restore from there using SIG_SETMASK. This has the intended effect of preserving the SIG_BLOCK on either SIGTERM or SIGINT if either was already blocked when entering this method in the parent thread. Existing behavior where either signal was not blocked prior to entering the resource tracker is still preserved since the SIG_SETMASK will undo the SIG_BLOCKs anyway if those signals were previously unblocked.

Please let me know if anything else is needed here, e.g. if a unit test is worthwhile here, I could take a stab tomorrow at writing one.

Copy link

cpython-cla-bot bot commented Dec 4, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

Using SIG_UNBLOCK to remove blocked "ignored signals" may accidentally
cause side effects if the calling parent already had said signals
blocked to begin with and did not intend to unblock them when
creating a pool. Use SIG_SETMASK instead with the previous mask of
blocked signals to restore the original blocked set.
@stephen-hansen stephen-hansen force-pushed the gh-127586-mp-pool-sigblock-fix branch from 85370c0 to 5e4797c Compare December 4, 2024 01:44
@stephen-hansen stephen-hansen changed the title gh-127586: properly restore blocked signals in resource_manager.py gh-127586: properly restore blocked signals in resource_tracker.py Dec 4, 2024
@ZeroIntensity ZeroIntensity added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Dec 10, 2024
@ZeroIntensity
Copy link
Member

Please let me know if anything else is needed here, e.g. if a unit test is worthwhile here, I could take a stab tomorrow at writing one.

That would be great. We generally require tests for all bugfixes.

@stephen-hansen
Copy link
Contributor Author

Please let me know if anything else is needed here, e.g. if a unit test is worthwhile here, I could take a stab tomorrow at writing one.

That would be great. We generally require tests for all bugfixes.

perfect, thanks. I've added a blocked signals test for resource tracker which should cover the issue.

One weird thing I've noticed is that on some of my build pipelines, I'm seeing random test failures for idlelib on macos-13, e.g. https://github.com/python/cpython/actions/runs/12301168597/job/34331141506?pr=127587. Some of the test failures appear similar to what was reported on #76152. Not sure if there is an implicit dependency between resource_tracker and those unit tests, that I broke, or if this is unrelated to my changes. I looked for a while but couldn't find any explanation. I also just don't know idlelib too well.

@ZeroIntensity
Copy link
Member

Yeah, those don't look related. Sometimes we get intermittent failures on some tests, generally not because of a bug in the code but because of a missing platform constraint on that test. I'm not sure if you have permissions to rerun failed CI jobs, so tag me if it happens and I'll do it.

pthread_sigmask is not available on some platforms

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
@gpshead gpshead self-assigned this Dec 15, 2024
@gpshead gpshead merged commit 46006a1 into python:main Dec 15, 2024
38 checks passed
@miss-islington-app
Copy link

Thanks @stephen-hansen for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 15, 2024
….py (pythonGH-127587)

* Correct pthread_sigmask in resource_tracker to restore old signals

Using SIG_UNBLOCK to remove blocked "ignored signals" may accidentally
cause side effects if the calling parent already had said signals
blocked to begin with and did not intend to unblock them when
creating a pool. Use SIG_SETMASK instead with the previous mask of
blocked signals to restore the original blocked set.

* Adding resource_tracker blocked signals test
(cherry picked from commit 46006a1)

Co-authored-by: Stephen Hansen <stephen.paul.hansen@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
@miss-islington-app
Copy link

Sorry, @stephen-hansen and @gpshead, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 46006a1b355f75d06c10e7b8086912c483b34487 3.12

@bedevere-app
Copy link

bedevere-app bot commented Dec 15, 2024

GH-127973 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Dec 15, 2024
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x RHEL9 Refleaks 3.x has failed when building commit 46006a1.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1589/builds/630) and take a look at the build logs.
  4. Check if the failure is related to this commit (46006a1) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1589/builds/630

Failed tests:

  • test.test_multiprocessing_fork.test_misc
  • test.test_multiprocessing_spawn.test_misc
  • test.test_multiprocessing_forkserver.test_misc

Failed subtests:

  • test_resource_tracker - test.test_multiprocessing_fork.test_misc.TestResourceTracker.test_resource_tracker
  • test_resource_tracker - test.test_multiprocessing_spawn.test_misc.TestResourceTracker.test_resource_tracker
  • test_resource_tracker - test.test_multiprocessing_forkserver.test_misc.TestResourceTracker.test_resource_tracker

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/test/_test_multiprocessing.py", line 5925, in test_resource_tracker
    self.assertRegex(err, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'resource_tracker: There appear to be 2 leaked semaphore objects' not found in 'Traceback (most recent call last):\n  File "/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/util.py", line 292, in _run_finalizers\n    finalizer()\n    ~~~~~~~~~^^\n  File "/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/util.py", line 216, in __call__\n    res = self._callback(*self._args, **self._kwargs)\n  File "/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/synchronize.py", line 86, in _cleanup\n    sem_unlink(name)\n    ~~~~~~~~~~^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory\n/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/resource_tracker.py:277: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown: {\'/mp-h604h0vv\'}\n  warnings.warn(\n/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/resource_tracker.py:293: UserWarning: resource_tracker: \'/mp-h604h0vv\': [Errno 2] No such file or directory\n  warnings.warn(\'resource_tracker: %r: %s\' % (name, e))\n'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/test/_test_multiprocessing.py", line 5925, in test_resource_tracker
    self.assertRegex(err, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'resource_tracker: There appear to be 2 leaked semaphore objects' not found in 'Traceback (most recent call last):\n  File "/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/util.py", line 292, in _run_finalizers\n    finalizer()\n    ~~~~~~~~~^^\n  File "/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/util.py", line 216, in __call__\n    res = self._callback(*self._args, **self._kwargs)\n  File "/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/synchronize.py", line 86, in _cleanup\n    sem_unlink(name)\n    ~~~~~~~~~~^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory\n/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/resource_tracker.py:277: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown: {\'/mp-4r4kmi3r\'}\n  warnings.warn(\n/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/resource_tracker.py:293: UserWarning: resource_tracker: \'/mp-4r4kmi3r\': [Errno 2] No such file or directory\n  warnings.warn(\'resource_tracker: %r: %s\' % (name, e))\n'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/test/_test_multiprocessing.py", line 5925, in test_resource_tracker
    self.assertRegex(err, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'resource_tracker: There appear to be 2 leaked semaphore objects' not found in 'Traceback (most recent call last):\n  File "/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/util.py", line 292, in _run_finalizers\n    finalizer()\n    ~~~~~~~~~^^\n  File "/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/util.py", line 216, in __call__\n    res = self._callback(*self._args, **self._kwargs)\n  File "/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/synchronize.py", line 86, in _cleanup\n    sem_unlink(name)\n    ~~~~~~~~~~^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory\n/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/resource_tracker.py:277: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown: {\'/mp-cchcz5dh\'}\n  warnings.warn(\n/home/buildbot/buildarea/3.x.cstratak-rhel9-s390x.refleak/build/Lib/multiprocessing/resource_tracker.py:293: UserWarning: resource_tracker: \'/mp-cchcz5dh\': [Errno 2] No such file or directory\n  warnings.warn(\'resource_tracker: %r: %s\' % (name, e))\n'

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 RHEL8 Refleaks 3.x has failed when building commit 46006a1.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/259/builds/1850) and take a look at the build logs.
  4. Check if the failure is related to this commit (46006a1) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/259/builds/1850

Failed tests:

  • test.test_multiprocessing_fork.test_misc
  • test.test_multiprocessing_spawn.test_misc
  • test.test_multiprocessing_forkserver.test_misc

Failed subtests:

  • test_resource_tracker - test.test_multiprocessing_fork.test_misc.TestResourceTracker.test_resource_tracker
  • test_resource_tracker - test.test_multiprocessing_forkserver.test_misc.TestResourceTracker.test_resource_tracker
  • test_resource_tracker - test.test_multiprocessing_spawn.test_misc.TestResourceTracker.test_resource_tracker

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 5925, in test_resource_tracker
    self.assertRegex(err, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'resource_tracker: There appear to be 2 leaked semaphore objects' not found in 'Traceback (most recent call last):\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/util.py", line 292, in _run_finalizers\n    finalizer()\n    ~~~~~~~~~^^\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/util.py", line 216, in __call__\n    res = self._callback(*self._args, **self._kwargs)\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/synchronize.py", line 86, in _cleanup\n    sem_unlink(name)\n    ~~~~~~~~~~^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory\n/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/resource_tracker.py:277: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown: {\'/mp-xh99_f9n\'}\n  warnings.warn(\n/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/resource_tracker.py:293: UserWarning: resource_tracker: \'/mp-xh99_f9n\': [Errno 2] No such file or directory\n  warnings.warn(\'resource_tracker: %r: %s\' % (name, e))\n'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 5925, in test_resource_tracker
    self.assertRegex(err, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'resource_tracker: There appear to be 2 leaked semaphore objects' not found in 'Traceback (most recent call last):\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/util.py", line 292, in _run_finalizers\n    finalizer()\n    ~~~~~~~~~^^\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/util.py", line 216, in __call__\n    res = self._callback(*self._args, **self._kwargs)\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/synchronize.py", line 86, in _cleanup\n    sem_unlink(name)\n    ~~~~~~~~~~^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory\n/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/resource_tracker.py:277: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown: {\'/mp-_fx_cbhe\'}\n  warnings.warn(\n/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/resource_tracker.py:293: UserWarning: resource_tracker: \'/mp-_fx_cbhe\': [Errno 2] No such file or directory\n  warnings.warn(\'resource_tracker: %r: %s\' % (name, e))\n'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 5925, in test_resource_tracker
    self.assertRegex(err, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'resource_tracker: There appear to be 2 leaked semaphore objects' not found in 'Traceback (most recent call last):\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/util.py", line 292, in _run_finalizers\n    finalizer()\n    ~~~~~~~~~^^\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/util.py", line 216, in __call__\n    res = self._callback(*self._args, **self._kwargs)\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/synchronize.py", line 86, in _cleanup\n    sem_unlink(name)\n    ~~~~~~~~~~^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory\n/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/resource_tracker.py:277: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown: {\'/mp-qy0i0jcq\'}\n  warnings.warn(\n/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.refleak/build/Lib/multiprocessing/resource_tracker.py:293: UserWarning: resource_tracker: \'/mp-qy0i0jcq\': [Errno 2] No such file or directory\n  warnings.warn(\'resource_tracker: %r: %s\' % (name, e))\n'

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Fedora Stable Refleaks 3.x has failed when building commit 46006a1.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/320/builds/1699) and take a look at the build logs.
  4. Check if the failure is related to this commit (46006a1) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/320/builds/1699

Failed tests:

  • test.test_multiprocessing_fork.test_misc
  • test.test_multiprocessing_spawn.test_misc
  • test.test_multiprocessing_forkserver.test_misc

Failed subtests:

  • test_resource_tracker - test.test_multiprocessing_fork.test_misc.TestResourceTracker.test_resource_tracker
  • test_resource_tracker - test.test_multiprocessing_forkserver.test_misc.TestResourceTracker.test_resource_tracker
  • test_resource_tracker - test.test_multiprocessing_spawn.test_misc.TestResourceTracker.test_resource_tracker

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 5925, in test_resource_tracker
    self.assertRegex(err, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'resource_tracker: There appear to be 2 leaked semaphore objects' not found in 'Traceback (most recent call last):\n  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/util.py", line 292, in _run_finalizers\n    finalizer()\n    ~~~~~~~~~^^\n  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/util.py", line 216, in __call__\n    res = self._callback(*self._args, **self._kwargs)\n  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/synchronize.py", line 86, in _cleanup\n    sem_unlink(name)\n    ~~~~~~~~~~^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory\n/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/resource_tracker.py:277: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown: {\'/mp-diuavsej\'}\n  warnings.warn(\n/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/resource_tracker.py:293: UserWarning: resource_tracker: \'/mp-diuavsej\': [Errno 2] No such file or directory\n  warnings.warn(\'resource_tracker: %r: %s\' % (name, e))\n'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 5925, in test_resource_tracker
    self.assertRegex(err, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'resource_tracker: There appear to be 2 leaked semaphore objects' not found in 'Traceback (most recent call last):\n  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/util.py", line 292, in _run_finalizers\n    finalizer()\n    ~~~~~~~~~^^\n  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/util.py", line 216, in __call__\n    res = self._callback(*self._args, **self._kwargs)\n  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/synchronize.py", line 86, in _cleanup\n    sem_unlink(name)\n    ~~~~~~~~~~^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory\n/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/resource_tracker.py:277: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown: {\'/mp-_idjhg2j\'}\n  warnings.warn(\n/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/resource_tracker.py:293: UserWarning: resource_tracker: \'/mp-_idjhg2j\': [Errno 2] No such file or directory\n  warnings.warn(\'resource_tracker: %r: %s\' % (name, e))\n'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/test/_test_multiprocessing.py", line 5925, in test_resource_tracker
    self.assertRegex(err, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'resource_tracker: There appear to be 2 leaked semaphore objects' not found in 'Traceback (most recent call last):\n  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/util.py", line 292, in _run_finalizers\n    finalizer()\n    ~~~~~~~~~^^\n  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/util.py", line 216, in __call__\n    res = self._callback(*self._args, **self._kwargs)\n  File "/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/synchronize.py", line 86, in _cleanup\n    sem_unlink(name)\n    ~~~~~~~~~~^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory\n/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/resource_tracker.py:277: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown: {\'/mp-wv8gyh8g\'}\n  warnings.warn(\n/home/buildbot/buildarea/3.x.cstratak-fedora-stable-x86_64.refleak/build/Lib/multiprocessing/resource_tracker.py:293: UserWarning: resource_tracker: \'/mp-wv8gyh8g\': [Errno 2] No such file or directory\n  warnings.warn(\'resource_tracker: %r: %s\' % (name, e))\n'

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot aarch64 RHEL8 Refleaks 3.x has failed when building commit 46006a1.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/551/builds/470) and take a look at the build logs.
  4. Check if the failure is related to this commit (46006a1) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/551/builds/470

Failed tests:

  • test.test_multiprocessing_fork.test_misc
  • test.test_multiprocessing_spawn.test_misc
  • test.test_multiprocessing_forkserver.test_misc

Failed subtests:

  • test_resource_tracker - test.test_multiprocessing_fork.test_misc.TestResourceTracker.test_resource_tracker
  • test_resource_tracker - test.test_multiprocessing_forkserver.test_misc.TestResourceTracker.test_resource_tracker

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.refleak/build/Lib/test/_test_multiprocessing.py", line 5925, in test_resource_tracker
    self.assertRegex(err, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'resource_tracker: There appear to be 2 leaked semaphore objects' not found in 'Traceback (most recent call last):\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.refleak/build/Lib/multiprocessing/util.py", line 292, in _run_finalizers\n    finalizer()\n    ~~~~~~~~~^^\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.refleak/build/Lib/multiprocessing/util.py", line 216, in __call__\n    res = self._callback(*self._args, **self._kwargs)\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.refleak/build/Lib/multiprocessing/synchronize.py", line 86, in _cleanup\n    sem_unlink(name)\n    ~~~~~~~~~~^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory\n/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.refleak/build/Lib/multiprocessing/resource_tracker.py:277: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown: {\'/mp-5ksl4jwh\'}\n  warnings.warn(\n/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.refleak/build/Lib/multiprocessing/resource_tracker.py:293: UserWarning: resource_tracker: \'/mp-5ksl4jwh\': [Errno 2] No such file or directory\n  warnings.warn(\'resource_tracker: %r: %s\' % (name, e))\n'


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.refleak/build/Lib/test/_test_multiprocessing.py", line 5925, in test_resource_tracker
    self.assertRegex(err, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: Regex didn't match: 'resource_tracker: There appear to be 2 leaked semaphore objects' not found in 'Traceback (most recent call last):\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.refleak/build/Lib/multiprocessing/util.py", line 292, in _run_finalizers\n    finalizer()\n    ~~~~~~~~~^^\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.refleak/build/Lib/multiprocessing/util.py", line 216, in __call__\n    res = self._callback(*self._args, **self._kwargs)\n  File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.refleak/build/Lib/multiprocessing/synchronize.py", line 86, in _cleanup\n    sem_unlink(name)\n    ~~~~~~~~~~^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory\n/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.refleak/build/Lib/multiprocessing/resource_tracker.py:277: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown: {\'/mp-xo0p7x29\'}\n  warnings.warn(\n/home/buildbot/buildarea/3.x.cstratak-RHEL8-aarch64.refleak/build/Lib/multiprocessing/resource_tracker.py:293: UserWarning: resource_tracker: \'/mp-xo0p7x29\': [Errno 2] No such file or directory\n  warnings.warn(\'resource_tracker: %r: %s\' % (name, e))\n'

@hugovk
Copy link
Member

hugovk commented Dec 16, 2024

The next 3.14 alpha release is tomorrow and these tier 1 and 2 buildbot failures are blocking it:

https://buildbot.python.org/#/release_status

Do you have an idea how to fix it or shall we revert this for now?

@hugovk
Copy link
Member

hugovk commented Dec 16, 2024

Revert PR in case we need it: #127983

@ZeroIntensity
Copy link
Member

I swear that I'm a buildbot failure magnet 😄

@stephen-hansen
Copy link
Contributor Author

Yeah, it looks like the cleanup test behavior might have changed. At first glance it looks like the previous behavior was that both semaphores would leak, guessing terminate() + wait() was immediate? Feels like it is now blocking on the subprocess, as name1 leaks as expected but name2 appears to be cleaned by its finalizer.. this feels correct to me but would appreciate if someone could confirm.

Guessing the fix is to change the 1 expected output line but for now happy to revert this. I’m going to investigate this more tonight.

hugovk added a commit that referenced this pull request Dec 16, 2024
@gpshead
Copy link
Member

gpshead commented Dec 16, 2024

thanks!

srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 8, 2025
….py (pythonGH-127587)

* Correct pthread_sigmask in resource_tracker to restore old signals

Using SIG_UNBLOCK to remove blocked "ignored signals" may accidentally
cause side effects if the calling parent already had said signals
blocked to begin with and did not intend to unblock them when
creating a pool. Use SIG_SETMASK instead with the previous mask of
blocked signals to restore the original blocked set.

* Adding resource_tracker blocked signals test

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs backport to 3.12 bug and security fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multiprocessing.Pool does not properly restore blocked signals
5 participants