Skip to content

Test failure in CI: test_ufunc_fixed_width_out_releases_buffer #33409

Done

Description

@rgommers

Observed in (this CI log](https://github.com/numpy/numpy-release/actions/runs/44977466535/job/137070536035) from the latest nightly wheels run on cp315t-musllinux-aarch64:

    __________________ test_ufunc_fixed_width_out_releases_buffer __________________
    [gw2] linux -- Python 3.15.2 /tmp/tmp.iGCAFk/venv/bin/python
    
        @pytest.mark.thread_unsafe(reason="tracemalloc is not thread-safe")
        def test_ufunc_fixed_width_out_releases_buffer():
            # the ufunc computes its StringDType results into a temporary buffer and
            # then casts them to the output array. The strings in the buffer leak
            # unless that cast frees them.
            def add():
                n = 2 * np.getbufsize()
                first = np.array([f"first name {i}" for i in range(n)], dtype="T")
                last = np.array([f"a longer last name, number {i}" for i in range(n)],
                                dtype="T")
                full = np.empty(n, dtype="U60")
                np.strings.add(first, last, out=full)
                assert full[-1] == first[-1] + last[-1]
        
    >       assert_memory_growth_below(add, limit=1024)
    
    add        = <function test_ufunc_fixed_width_out_releases_buffer.<locals>.add at 0x58259a90e40>
    
    ../venv/lib/python3.15t/site-packages/numpy/_core/tests/test_stringdtype.py:1019: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    func = <function test_ufunc_fixed_width_out_releases_buffer.<locals>.add at 0x58259a90e40>
    limit = 1024, repeat = 10
    
        def assert_memory_growth_below(func, limit, repeat=10):
            """Fail if more than ``limit`` bytes are still allocated after calling
            ``func()`` ``repeat`` times.
        
            ``func`` is called once before the measurement starts.  This uses
            `tracemalloc` and is not thread-safe.
            """
            func()
            with trace_memory_growth() as growth:
                for _ in range(repeat):
                    func()
    >       assert growth() < limit, (
                   ^^^^^^^^^^^^^^^^
                f"memory grew by {growth()} bytes after {repeat} calls, "
                f"limit is {limit}")
    E       AssertionError: memory grew by 61248 bytes after 10 calls, limit is 1024
    
    _          = 9
    func       = <function test_ufunc_fixed_width_out_releases_buffer.<locals>.add at 0x58259a90e40>
    growth     = <function trace_memory_growth.<locals>.growth at 0x58259a93f00>
    limit      = 1024
    repeat     = 10
    
    ../venv/lib/python3.15t/site-packages/numpy/testing/_private/utils.py:3080: AssertionError

Cc @ngoldbaum

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions