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

Automatically disable pymalloc when running under valgrind #46674

Closed
jamesh mannequin opened this issue Mar 19, 2008 · 10 comments
Closed

Automatically disable pymalloc when running under valgrind #46674

jamesh mannequin opened this issue Mar 19, 2008 · 10 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@jamesh
Copy link
Mannequin

jamesh mannequin commented Mar 19, 2008

BPO 2422
Nosy @tiran, @rbtcollins, @benjaminp, @davidmalcolm
Files
  • disable-pymalloc-on-valgrind.patch: disable-pymalloc-on-valgrind.patch
  • disable-pymalloc-on-valgrind-v3.patch: version 3
  • disable-pymalloc-on-valgrind-26.diff: patch with configure option for 2.6
  • disable-pymalloc-on-valgrind-py26.patch: Python 2.6 version of previous patch.
  • disable-pymalloc-on-valgrind-py26.patch: Python 2.6 patch (v2)
  • disable-pymalloc-on-valgrind-py27.patch: Python 2.7 patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2009-12-03.02:58:00.106>
    created_at = <Date 2008-03-19.11:11:08.362>
    labels = ['interpreter-core', 'type-feature']
    title = 'Automatically disable pymalloc when running under valgrind'
    updated_at = <Date 2009-12-03.02:58:00.096>
    user = 'https://bugs.python.org/jamesh'

    bugs.python.org fields:

    activity = <Date 2009-12-03.02:58:00.096>
    actor = 'benjamin.peterson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-12-03.02:58:00.106>
    closer = 'benjamin.peterson'
    components = ['Interpreter Core']
    creation = <Date 2008-03-19.11:11:08.362>
    creator = 'jamesh'
    dependencies = []
    files = ['9765', '9781', '9835', '9837', '9872', '12935']
    hgrepos = []
    issue_num = 2422
    keywords = ['patch']
    message_count = 10.0
    messages = ['64052', '64139', '64255', '64390', '64393', '64575', '64837', '64840', '81124', '95923']
    nosy_count = 6.0
    nosy_names = ['jamesh', 'christian.heimes', 'rbcollins', 'benjamin.peterson', 'lauromoura', 'dmalcolm']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue2422'
    versions = ['Python 2.6']

    @jamesh
    Copy link
    Mannequin Author

    jamesh mannequin commented Mar 19, 2008

    When I want to use valgrind to check for leaks in a Python program (or
    test suite), I generally want pymalloc disabled. When not running
    valgrind I generally want it enabled.

    Attached is a patch that automatically bypasses the pymalloc code when
    running under valgrind but leaves it enabled overwise.

    It is controlled by a WITH_VALGRIND #define, but I haven't updated the
    configure script to allow turning it on. I also haven't done much in
    the way of profiling to see what the overhead is when not running under
    valgrind.

    @jamesh jamesh mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Mar 19, 2008
    @jamesh
    Copy link
    Mannequin Author

    jamesh mannequin commented Mar 20, 2008

    A slightly cleaned up version of the previous patch. I only needed to
    include <valgrind/valgrind.h>.

    @tiran
    Copy link
    Member

    tiran commented Mar 21, 2008

    Please provide a patch for Python 2.6 that includes a ./configure
    --with-valgrind option. We may consider such a patch for 2.6 and 3.0 but
    definitely not for 2.5.

    @lauromoura
    Copy link
    Mannequin

    lauromoura mannequin commented Mar 24, 2008

    Here's a patch with James changes to obmalloc and a --with-valgrind
    option in configure.in.

    @jamesh
    Copy link
    Mannequin Author

    jamesh mannequin commented Mar 24, 2008

    Here's the updated version of my patch (the obmalloc.c bits applied
    without conflicts to the newer source tree).

    The configure changes are a bit different to Lauro's ones, in that they
    check for the existence of the <valgrind/valgrind.h> header if Valgrind
    support was requested.

    @jamesh
    Copy link
    Mannequin Author

    jamesh mannequin commented Mar 27, 2008

    An updated version of the patch. The previous ones were missing the
    valgrind check, resulting in the pymalloc code paths being executed
    (which in turn cause unintialised read warnings from valgrind).

    @jamesh
    Copy link
    Mannequin Author

    jamesh mannequin commented Apr 2, 2008

    There are probably a few other performance optimisations that would be
    good to turn off when running under valgrind.

    A big one is the tuple cache: if there are tuple reference counting
    issues, they won't necessarily be seen by valgrind if the tuple is kept
    and reused rather than being freed.

    @tiran
    Copy link
    Member

    tiran commented Apr 2, 2008

    James Henstridge schrieb:

    James Henstridge <james@jamesh.id.au> added the comment:

    There are probably a few other performance optimisations that would be
    good to turn off when running under valgrind.

    A big one is the tuple cache: if there are tuple reference counting
    issues, they won't necessarily be seen by valgrind if the tuple is kept
    and reused rather than being freed.

    The tuple cache can't be disabled entirely. Some parts of Python and
    some third party modules may depend on the fact that an empty tuple ()
    is a singleton in Python.

    The tuple cache could be reduced to empty tuple and some other caches
    like the list and dict cache could be disabled entirely.

    Christian

    @jamesh
    Copy link
    Mannequin Author

    jamesh mannequin commented Feb 4, 2009

    Attached is an updated version of the patch against trunk (2.7). It
    simply fixes the conflicts that have occurred since the previous patch.

    @benjaminp
    Copy link
    Contributor

    Thank you. Applied in r76644.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants