GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test_regrtest: test_huntrleaks() fails randomly: leaked [9, 1, 1] references · Issue #109739 · python/cpython

test_regrtest: test_huntrleaks() fails randomly: leaked [9, 1, 1] references #109739

New issue
Copy link
New issue
Copy link
Closed
Closed
test_regrtest: test_huntrleaks() fails randomly: leaked [9, 1, 1] references#109739
Copy link
Labels
OS-windowstestsTests in the Lib/test dirTests in the Lib/test dir

Description

@vstinner
vstinner
opened on Sep 22, 2023
Issue body actions

Failure on GHA Windows x86 CI:

FAIL: test_huntrleaks (test.test_regrtest.ArgsTestCase.test_huntrleaks)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\cpython\cpython\Lib\test\test_regrtest.py", line 1068, in test_huntrleaks
    self.check_huntrleaks(run_workers=False)
  File "D:\a\cpython\cpython\Lib\test\test_regrtest.py", line 1065, in check_huntrleaks
    self.check_leak(code, 'references', run_workers=run_workers)
  File "D:\a\cpython\cpython\Lib\test\support\__init__.py", line 2564, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "D:\a\cpython\cpython\Lib\test\test_regrtest.py", line 1047, in check_leak
    self.assertIn(line2, output)
AssertionError:

'test_regrtest_huntrleaks leaked [1, 1, 1] references, sum=3\n' 

not found in

'0:00:00 Run 1 test sequentially\n
0:00:00 [1/1] test_regrtest_huntrleaks\n
beginning 6 repetitions\n
123456\n
......\n
test_regrtest_huntrleaks leaked [9, 1, 1] references, sum=11\n
test_regrtest_huntrleaks leaked [1, 1, 1] memory blocks, sum=3\n
test_regrtest_huntrleaks failed (reference leak)\n
\n
== Tests result: FAILURE ==\n
\n
1 test failed:\n
    test_regrtest_huntrleaks\n
\n
Total duration: 292 ms\n
Total tests: run=1\n
Total test files: run=1/1 failed=1\n
Result: FAILURE\n'

build: https://github.com/python/cpython/actions/runs/6274556366/job/17041487300?pr=109727

Linked PRs

  • gh-109739: regrtest disables load tracker if refleak #109871

Activity

  1. vstinner
    added
    testsTests in the Lib/test dirTests in the Lib/test dir
    on Sep 22, 2023
  2. sobolevn
    added
    OS-windows
    on Sep 23, 2023
  3. vstinner commented on Sep 25, 2023

    @vstinner
    vstinner
    on Sep 25, 2023
    MemberAuthor
    More actions

    Windows x64: https://github.com/python/cpython/actions/runs/6299520741/job/17100438819?pr=109831

  4. vstinner commented on Sep 25, 2023

    @vstinner
    vstinner
    on Sep 25, 2023
    MemberAuthor
    More actions

    I cannot reproduce the issue on Linux. I stopped the stress test after 19 minutes:

    vstinner@mona$ ./python -m test -v test_regrtest -m 'test_huntrleaks*' -v --forever -j10 -r
    (...)
    0:19:19 load avg: 11.84 [1770] test_regrtest passed
    
  5. vstinner commented on Sep 25, 2023

    @vstinner
    vstinner
    on Sep 25, 2023
    MemberAuthor
    More actions

    I failed to reproduce the issue on Windows with this command:

    vstinner@WIN C:\victor\python\main>python -m test -v test_regrtest -m test.test_regrtest.ArgsTestCase.test_huntrleaks -v --forever
    (...)
    0:17:19 load avg: 0.23 [1371] test_regrtest
    test_huntrleaks (test.test_regrtest.ArgsTestCase.test_huntrleaks) ... ok
    
    ----------------------------------------------------------------------
    Ran 1 test in 0.676s
    
    OK
    
    ^C
    

    I interrupted the test after 17 minutes.

  6. vstinner commented on Sep 25, 2023

    @vstinner
    vstinner
    on Sep 25, 2023
    MemberAuthor
    More actions

    To reproduce the issue on Windows, create the file Lib\test\test_leak.py:

    import unittest
    
    GLOBAL_LIST = []
    
    class RefLeakTest(unittest.TestCase):
        def test_leak(self):
            GLOBAL_LIST.append(object())

    And run the script leak.py:

    import sys
    import subprocess
    
    while True:
        sys.stdout.write(".")
        sys.stdout.flush()
    
        cmd = [sys.executable, "-m", "test", "-R", "3:3", "test_leak"]
        proc = subprocess.run(cmd,
                              stdout=subprocess.PIPE,
                              stderr=subprocess.STDOUT,
                              text=True)
        if "test_leak leaked [1, 1, 1] references" in proc.stdout:
            continue
    
        print(proc.stdout, end="")
        if proc.returncode:
            print(f"FAILED: exit code {proc.returncode}")
            break
  7. vstinner commented on Sep 25, 2023

    @vstinner
    vstinner
    on Sep 25, 2023
    MemberAuthor
    More actions

    And run the script leak.py:

    And more the system less determistic by running the following command in a different terminal:

    python -m test -j1 -r --forever
    

    Example of the bug on Windows:

    vstinner@WIN C:\victor\python\main>python leak.py
    Running Debug|x64 interpreter...
    ........................0:00:00 Run 1 test sequentially
    0:00:00 [1/1] test_leak
    beginning 6 repetitions
    123456
    ......
    test_leak leaked [9, 1, 1] references, sum=11
    test_leak leaked [1, 1, 1] memory blocks, sum=3
    test_leak failed (reference leak)
    
    == Tests result: FAILURE ==
    
    1 test failed:
        test_leak
    
    Total duration: 237 ms
    Total tests: run=1
    Total test files: run=1/1 failed=1
    Result: FAILURE
    FAILED: exit code 2
    
  8. vstinner commented on Sep 25, 2023

    @vstinner
    vstinner
    on Sep 25, 2023
    MemberAuthor
    More actions

    I can still reproduce the leak even if I disable the bytecode specialization.

    diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h
    index a77fa11baf..7de6384574 100644
    --- a/Include/internal/pycore_code.h
    +++ b/Include/internal/pycore_code.h
    @@ -236,7 +236,7 @@ extern int _PyLineTable_PreviousAddressRange(PyCodeAddressRange *range);
     /** API for executors */
     extern void _PyCode_Clear_Executors(PyCodeObject *code);
    
    -#define ENABLE_SPECIALIZATION 1
    +#define ENABLE_SPECIALIZATION 0
    
     /* Specialization functions */
    
  9. vstinner commented on Sep 25, 2023

    @vstinner
    vstinner
    on Sep 25, 2023
    MemberAuthor
    More actions

    "before" variables when the bug occurs:

    test_leak leaked [9, 1, 1] references, sum=11
    test_leak leaked [1, 1, 1] memory blocks, sum=3
    interned_before=12109
    alloc_before=61013
    rc_before=94336
    fd_before=3
    

    "before" variables when the bug does not occur:

    interned_before=12109
    alloc_before=61013
    rc_before=94333
    fd_before=3
    test_leak leaked [1, 1, 1] references, sum=3
    

    Only rc_before is different: 94 333 (ok) => 94 336 (bug).

  10. vstinner commented on Sep 25, 2023

    @vstinner
    vstinner
    on Sep 25, 2023
    MemberAuthor
    More actions

    Oooooooh, the issue comes from regrtest logger: from WindowsLoadTracker thread.

  11. vstinner
    added 6 commits that reference this issue on Sep 25, 2023

    pythongh-109739: regrtest disables load tracker if refleak

    c9ccb80

    pythongh-109739: regrtest disables load tracker if refleak

    10b0d91

    pythongh-109739: regrtest disables load tracker if refleak

    9fdae73

    pythongh-109739: regrtest disables load tracker if refleak

    d3a0ac9

    pythongh-109739: regrtest disables load tracker if refleak

    582f4bd

    gh-109739: regrtest disables load tracker if refleak (#109871)

    4091deb
  12. vstinner
    closed this as completedon Sep 26, 2023
  13. csm10495
    added a commit that references this issue on Sep 28, 2023

    pythongh-109739: regrtest disables load tracker if refleak (python#10…

    8e7d778
  14. Glyphack
    added a commit that references this issue on Sep 2, 2024

    pythongh-109739: regrtest disables load tracker if refleak (python#10…

    470adc5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowstestsTests in the Lib/test dirTests in the Lib/test dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.