Skip to content
This repository was archived by the owner on Apr 23, 2024. It is now read-only.
This repository was archived by the owner on Apr 23, 2024. It is now read-only.

profiler.py:ProfilerWSGIMiddleware:__call__ is not threadsafe #78

@holte

Description

@holte

This method seems to have a race condition that eventually leads to max recursion depth exceeded errors:

The code has the following pattern:

old_memcache_add = memcache.add
memcache.add = (lambda ... : ... old_memcache_add)
...
memcache.add = old_memcache_add

If this is executed by two threads in a particular order it leaves memcache.add in the wrong state, e.g.:

Thread 1: old_memcache_add = memcache.add [1.old_memcache_add = MA]
Thread 1: memcache.add = (lambda ... : ... old_memcache_add) [ memcache.add = L(MA)]
Thread 2: old_memcache_add = memcache.add [2.old_memcache_add = L(MA)]
Thread 2: memcache.add = (lambda ... : ... old_memcache_add) [ memcache.add = L(L(MA))]
Thread 1: memcache.add = old_memcache_add [ memcache.add = MA]
Thread 2: memcache.add = old_memcache_add [ memcache.add = L(MA)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions