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

bpo-38119: Fix shmem resource tracking #15989

Closed
wants to merge 3 commits into from

Conversation

applio
Copy link
Member

@applio applio commented Sep 11, 2019

Eliminates the use of the resource tracker on shared memory segments but preserves its use on semaphores, etc. where it is appropriately applied.

Adds a test that fails with the current code (an independent Python process started via subprocess accesses shared memory created by a different Python process, then exits normally, expecting the original creator process to continue to be able to access that shared memory) but passes with this patch to defend against future regressions.

https://bugs.python.org/issue38119

@vinay0410
Copy link
Contributor

Updated PR fixing merge conflicts.

@vinay0410
Copy link
Contributor

vinay0410 commented Sep 2, 2020

@lihaoxiang1989 , this PR has merge conflicts, I have created a PR fixing those, containing the same changes. Can you approve that instead.
Updated PR.

@lthakur007
Copy link

Hello Team,
As am facing the same issue for which this PR has a solution.

May I know, once the PR is merged, how can I get the fix on Ubuntu 18.04?

@vinay0410
Copy link
Contributor

@lthakur007 , these changes are now being tracked by #21516, once those changes are merged you can either wait for an alpha or beta tag release, or you can directly build python from source (master).

@lthakur007
Copy link

@lthakur007 , these changes are now being tracked by #21516, once those changes are merged you can either wait for an alpha or beta tag release, or you can directly build python from source (master).

Thank you for the response.

@tiran tiran removed their request for review April 17, 2021 21:15
@ambv ambv removed the needs backport to 3.8 only security fixes label May 4, 2021
Copy link

@zhuowater zhuowater left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea,it works,nice job!

@atarashansky
Copy link

Astonishing that this is still not merged... I've been manually unregistering shared memory from child processes for the last year. What's the point of shared memory if it doesn't persist between processes by default...

@jcarlitooliveira
Copy link

any news on this?

@buzmeg
Copy link

buzmeg commented Nov 30, 2023

@jcarlitooliveira Does #82300 help you in any way?

@gpshead
Copy link
Member

gpshead commented Nov 30, 2023

there's an updated PR mentioned above: #21516 - it has a lot more discussion on it so i'm closing this earlier version of the proposed change.

@gpshead gpshead closed this Nov 30, 2023
@jcarlitooliveira
Copy link

@jcarlitooliveira Does #82300 help you in any way?

im using this monkey patch at the beginning of the application:

TODO: CHANGE FIX REGISTER/UNREGISTER TO INCLUDE SEMAPHORES

def remove_shm_from_resource_tracker():
"""Monkey-patch multiprocessing.resource_tracker so SharedMemory won't be tracked

More details at: https://bugs.python.org/issue38119
"""

def fix_register(name, rtype):
    if rtype == "shared_memory":
        return
    return resource_tracker._resource_tracker.register(self, name, rtype)
resource_tracker.register = fix_register

def fix_unregister(name, rtype):
    if rtype == "shared_memory":
        return
    return resource_tracker._resource_tracker.unregister(self, name, rtype)
resource_tracker.unregister = fix_unregister

if "shared_memory" in resource_tracker._CLEANUP_FUNCS:
    del resource_tracker._CLEANUP_FUNCS["shared_memory"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.