Skip to content

test_capi failure when GIL disabled #115891

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

Closed
smontanaro opened this issue Feb 24, 2024 · 3 comments
Closed

test_capi failure when GIL disabled #115891

smontanaro opened this issue Feb 24, 2024 · 3 comments
Assignees
Labels
3.13 bugs and security fixes topic-free-threading type-bug An unexpected behavior, bug, or error

Comments

@smontanaro
Copy link
Contributor

smontanaro commented Feb 24, 2024

Bug report

Bug description:

test_capi is failing reliably for me on Ubuntu 22.04 (Intel) and MacOS Sonoma (M1 Pro). Repeat with:

git clean -fdx
./configure
make
./python -E  -m test --fast-ci --timeout= test_capi
# test_capi succeeds
git clean -fdx
./configure --disable-gil
make
./python -E  -m test --fast-ci --timeout= test_capi
# test_capi fails

Output:

FAIL: test_pyobject_freed_is_freed (test.test_capi.test_mem.PyMemDebugTests.test_pyobject_freed_is_freed)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/skip/src/python/cpython/Lib/test/test_capi/test_mem.py", line 113, in test_pyobject_freed_is_freed
    self.check_pyobject_is_freed('check_pyobject_freed_is_freed')
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/skip/src/python/cpython/Lib/test/test_capi/test_mem.py", line 97, in check_pyobject_is_freed
    assert_python_ok(
    ~~~~~~~~~~~~~~~~^
        '-c', code,
        ^^^^^^^^^^^
        PYTHONMALLOC=self.PYTHONMALLOC,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        MALLOC_CONF="junk:false",
        ^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/skip/src/python/cpython/Lib/test/support/script_helper.py", line 180, in assert_python_ok
    return _assert_python(True, *args, **env_vars)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/skip/src/python/cpython/Lib/test/support/script_helper.py", line 165, in _assert_python
    res.fail(cmd_line)
    ~~~~~~~~^^^^^^^^^^
  File "/Users/skip/src/python/cpython/Lib/test/support/script_helper.py", line 75, in fail
    raise AssertionError("Process return code is %d\n"
    ...<13 lines>...
                            err))
AssertionError: Process return code is 1
command line: ['/Users/skip/src/python/cpython/python.exe', '-X', 'faulthandler', '-c', '\nimport gc, os, sys, _testinternalcapi\n# Disable the GC to avoid crash on GC collection\ngc.disable()\n_testinternalcapi.check_pyobject_freed_is_freed()\n# Exit immediately to avoid a crash while deallocating\n# the invalid object\nos._exit(0)\n']

stdout:
---

---

stderr:
---
Traceback (most recent call last):
  File "<string>", line 5, in <module>
    _testinternalcapi.check_pyobject_freed_is_freed()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
AssertionError: object is not seen as freed
---

I tried this on both MacOS Sonoma (14.3) and Dell (Intel) Ubuntu 22.04. Results were the same.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux, macOS

Linked PRs

@smontanaro smontanaro added the type-bug An unexpected behavior, bug, or error label Feb 24, 2024
@Eclips4
Copy link
Member

Eclips4 commented Feb 24, 2024

Confirmed on Windows, Linux and macOS (M1).

@Eclips4 Eclips4 added the 3.13 bugs and security fixes label Feb 24, 2024
@Eclips4
Copy link
Member

Eclips4 commented Feb 24, 2024

Bisected to 347acde
cc @colesbury

@colesbury colesbury self-assigned this Feb 27, 2024
colesbury added a commit to colesbury/cpython that referenced this issue Feb 28, 2024
The previous code had two bugs. First, the debug offset in the mimalloc
heap includes the two pymalloc debug words, but the pointer passed to
fill_mem_debug does not include them. Second, the current object heap is
correct source for allocations, but not deallocations.
colesbury added a commit to colesbury/cpython that referenced this issue Feb 28, 2024
The previous code had two bugs. First, the debug offset in the mimalloc
heap includes the two pymalloc debug words, but the pointer passed to
fill_mem_debug does not include them. Second, the current object heap is
correct source for allocations, but not deallocations.
DinoV pushed a commit that referenced this issue Feb 28, 2024
The previous code had two bugs. First, the debug offset in the mimalloc
heap includes the two pymalloc debug words, but the pointer passed to
fill_mem_debug does not include them. Second, the current object heap is
correct source for allocations, but not deallocations.
@colesbury
Copy link
Contributor

Fixed in #116018

woodruffw pushed a commit to woodruffw-forks/cpython that referenced this issue Mar 4, 2024
…n#116018)

The previous code had two bugs. First, the debug offset in the mimalloc
heap includes the two pymalloc debug words, but the pointer passed to
fill_mem_debug does not include them. Second, the current object heap is
correct source for allocations, but not deallocations.
adorilson pushed a commit to adorilson/cpython that referenced this issue Mar 25, 2024
…n#116018)

The previous code had two bugs. First, the debug offset in the mimalloc
heap includes the two pymalloc debug words, but the pointer passed to
fill_mem_debug does not include them. Second, the current object heap is
correct source for allocations, but not deallocations.
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
…n#116018)

The previous code had two bugs. First, the debug offset in the mimalloc
heap includes the two pymalloc debug words, but the pointer passed to
fill_mem_debug does not include them. Second, the current object heap is
correct source for allocations, but not deallocations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes topic-free-threading type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants