Skip to content

running test_ctypes 25 times in a row causes it to fail #45938

Closed

Description

@gvanrossum
BPO 1597
Nosy @gvanrossum, @theller

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/theller'
closed_at = <Date 2007-12-12.17:46:44.461>
created_at = <Date 2007-12-11.23:41:07.842>
labels = []
title = 'running test_ctypes 25 times in a row causes it to fail'
updated_at = <Date 2007-12-12.20:33:51.118>
user = 'https://github.com/gvanrossum'

bugs.python.org fields:

activity = <Date 2007-12-12.20:33:51.118>
actor = 'theller'
assignee = 'theller'
closed = True
closed_date = <Date 2007-12-12.17:46:44.461>
closer = 'gvanrossum'
components = []
creation = <Date 2007-12-11.23:41:07.842>
creator = 'gvanrossum'
dependencies = []
files = []
hgrepos = []
issue_num = 1597
keywords = []
message_count = 5.0
messages = ['58476', '58503', '58505', '58506', '58507']
nosy_count = 2.0
nosy_names = ['gvanrossum', 'theller']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1597'
versions = ['Python 3.0']

Activity

  1. gvanrossum commented on Dec 11, 2007

    @gvanrossum
    MemberAuthor

    In debug mode, on my Ubuntu Linux box, this fails on the last iteration:

    $ ./python Lib/test/regrtest.py -R:20 test_ctypes
    test_ctypes
    beginning 25 repetitions
    1234567890123456789012345
    ........................test test_ctypes failed -- Traceback (most
    recent call last):
      File
    "/usr/local/google/home/guido/python/py3kd/Lib/ctypes/test/test_values.py",
    line 18, in test_an_integer
        self.failUnlessEqual(x*2, ctdll.get_an_integer())
    AssertionError: 2818572288 != -1476395008

    1 test failed:
    test_ctypes
    [104230 refs]
    $

    Also, when using -R:19, I get some random leaks reported of 33 or -33
    references leaked. Does this test use threads? It seems to have a race
    condition.

  2. gvanrossum commented on Dec 12, 2007

    @gvanrossum
    MemberAuthor

    Thanks! (I agree with Eric Smith that this is mysterious for the
    innocent bystander.)

    Also, what about the -33/+33 leaks? I suppose these are harmless, but
    it would be better if the test reliably didn't report leaks...

  3. theller commented on Dec 12, 2007

    @theller

    Guido van Rossum schrieb:

    Thanks! (I agree with Eric Smith that this is mysterious for the
    innocent bystander.)

    I have added a comment.

    Also, what about the -33/+33 leaks? I suppose these are harmless, but
    it would be better if the test reliably didn't report leaks...

    I am using my own definition of leaking: a test is leaking if references
    grow without bounds ;-).

    Ok, I found that the test in charge is Lib/ctypes/test/test_loading.py,
    LoaderTest.test_find. This test uses the ctypes.util.find_library function,
    which contains several calls to os.popen(...).read().

    The minimal code reporting the -33/+33 leaks that I found is simply this:

    os.popen('ls').read()

    Is there a problem in "os.popen(...)", or do I something wrong here?

  4. gvanrossum commented on Dec 12, 2007

    @gvanrossum
    MemberAuthor

    The minimal code reporting the -33/+33 leaks that I found is simply this:

    os.popen('ls').read()

    Is there a problem in "os.popen(...)", or do I something wrong here?

    Try this instead:

     p = os.popen('ls')
     try:
       x = p.read()
     finally:
       p.close()

    IOW close the pipe explicitly. That should make the code execute in a
    more reproducible fashion. I've fixed this in ctypes/util.py now:
    r59477.

  5. theller commented on Dec 12, 2007

    @theller

    more reproducible fashion. I've fixed this in ctypes/util.py now:
    r59477.

    Cool! And the 'leak' is gone.

  6. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions