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

Python reinitialization test #46269

Closed
tiran opened this issue Jan 30, 2008 · 12 comments
Closed

Python reinitialization test #46269

tiran opened this issue Jan 30, 2008 · 12 comments
Assignees
Labels
build The build process and cross-build interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@tiran
Copy link
Member

tiran commented Jan 30, 2008

BPO 1977
Nosy @loewis, @pitrou, @tiran
Superseder
  • bpo-10914: Python sub-interpreter test
  • Files
  • test_reinit.patch
  • test_reinit.c
  • 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 = 'https://github.com/pitrou'
    closed_at = <Date 2012-11-26.20:00:28.290>
    created_at = <Date 2008-01-30.19:10:43.009>
    labels = ['interpreter-core', 'type-feature', 'build']
    title = 'Python reinitialization test'
    updated_at = <Date 2012-11-26.20:00:28.288>
    user = 'https://github.com/tiran'

    bugs.python.org fields:

    activity = <Date 2012-11-26.20:00:28.288>
    actor = 'pitrou'
    assignee = 'pitrou'
    closed = True
    closed_date = <Date 2012-11-26.20:00:28.290>
    closer = 'pitrou'
    components = ['Build', 'Interpreter Core']
    creation = <Date 2008-01-30.19:10:43.009>
    creator = 'christian.heimes'
    dependencies = []
    files = ['9334', '9339']
    hgrepos = []
    issue_num = 1977
    keywords = ['patch']
    message_count = 12.0
    messages = ['61873', '61875', '61876', '61895', '61899', '61904', '83564', '116941', '116958', '126329', '176420', '176448']
    nosy_count = 4.0
    nosy_names = ['loewis', 'pitrou', 'christian.heimes', 'BreamoreBoy']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = None
    status = 'closed'
    superseder = '10914'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue1977'
    versions = ['Python 3.2']

    @tiran
    Copy link
    Member Author

    tiran commented Jan 30, 2008

    The patch adds a new test and a new executable. The executable calls
    Py_Initialze() and Py_Finalize() multiple times in a row. The test also
    shows that Python looses about 35 references in each round.

    $ ./test_reinit
    round 1
    [7751 refs]
    round 2
    [7797 refs]
    round 3
    [7834 refs]
    round 4
    [7871 refs]
    round 5
    [7908 refs]
    round 6
    [7945 refs]
    round 7
    [7982 refs]
    round 8
    [8019 refs]
    round 9
    [8056 refs]
    round 10
    [8093 refs]

    @tiran tiran added build The build process and cross-build interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Jan 30, 2008
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jan 30, 2008

    I'm not sure what the purpose of this test is. When would it pass, when
    would it fail? I don't think it is a bug if a
    Py_Initialize()/Py_Finalize() cycle loses references.

    @tiran
    Copy link
    Member Author

    tiran commented Jan 30, 2008

    Martin v. Löwis wrote:

    Martin v. Löwis added the comment:

    I'm not sure what the purpose of this test is. When would it pass, when
    would it fail? I don't think it is a bug if a
    Py_Initialize()/Py_Finalize() cycle loses references.

    Today my attempts to fix some reference leaks related to sys.flags and
    sys.float_info caused the test to fail. A single init/final cycle worked
    but the second cycle broke.

    The test also shows an issue in Python 3.0. The double linked reference
    list is broken:

    $ ./test_reinit
    round 1
    [24676 refs]
    round 2
    [25588 refs]
    round 3
    * ob
    object  : <refcnt 0 at 0x82248e8>
    type    : str
    refcount: 0
    address : 0x82248e8
    * op->_ob_prev->_ob_next
    object  : <refcnt 0 at 0x82248e8>
    type    : str
    refcount: 0
    address : 0x82248e8
    * op->_ob_next->_ob_prev
    object  : bytearray(b'')
    type    : bytearray
    refcount: 1
    address : 0x839ab98
    Fatal Python error: UNREF invalid object
    Aborted (core dumped)

    @pitrou
    Copy link
    Member

    pitrou commented Jan 31, 2008

    Perhaps ROUNDS, CAUSE_SEGFAULT and VERBOSE could be command-line rather
    than compile-time options?

    @tiran
    Copy link
    Member Author

    tiran commented Jan 31, 2008

    I like to keep the test as simple as possible.

    Here is a new file that shows Python crashes in the third Py_Finalize().

    @tiran
    Copy link
    Member Author

    tiran commented Jan 31, 2008

    If fixed the problem with multiple reinitialization in r60477. It took
    me quite some time to find the right spot.

    @pitrou
    Copy link
    Member

    pitrou commented Mar 14, 2009

    This is still a good idea.

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Sep 20, 2010

    Quote msg83564 "This is still a good idea.", in which case shouldn't someone push this forward, failing that close as out of date?

    @pitrou
    Copy link
    Member

    pitrou commented Sep 20, 2010

    Quote msg83564 "This is still a good idea.", in which case shouldn't
    someone push this forward, failing that close as out of date?

    Just because someone doesn't "push this forward" doesn't mean it's out of date.

    @pitrou
    Copy link
    Member

    pitrou commented Jan 15, 2011

    See also bpo-10914.

    @tiran
    Copy link
    Member Author

    tiran commented Nov 26, 2012

    Antoine, is the test still required? bpo-10914 has introduced tests for the subinterpreter.

    @pitrou
    Copy link
    Member

    pitrou commented Nov 26, 2012

    Ah, funny. I ended up doing the same thing as you without remembering about it!

    @pitrou pitrou closed this as completed Nov 26, 2012
    @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
    build The build process and cross-build 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