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_sys.SysModuleTest.get_allocated_blocks` test precondition intermittently fails on iOS · Issue #130384 · python/cpython

test_sys.SysModuleTest.get_allocated_blocks test precondition intermittently fails on iOS #130384

New issue
Copy link
New issue
Copy link
Closed
Closed
test_sys.SysModuleTest.get_allocated_blocks test precondition intermittently fails on iOS#130384
Copy link
Labels
3.14bugs and security fixesbugs and security fixesOS-iostestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@freakboy3742
freakboy3742
opened on Feb 20, 2025
Issue body actions

Bug report

Bug description:

#130007 introduced a change to the handling of C stack limits. This change intermittently causes the test_sys.SysModuleTest.get_allocated_blocks() test to fail:

======================================================================
FAIL: test_getallocatedblocks (test.test_sys.SysModuleTest.test_getallocatedblocks)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/buildbot/Library/Developer/XCTestDevices/AFB8404B-0B3C-4CD4-862A-BBCE48F86959/data/Containers/Bundle/Application/91D9D3A2-F680-47B8-AC8F-A68603BDDACC/iOSTestbed.app/python/lib/python3.14/test/test_sys.py", line 1104, in test_getallocatedblocks
    self.assertLess(a, sys.gettotalrefcount())
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 548518 not less than 476363
----------------------------------------------------------------------

The exact values vary, but they're usually within ~500 or so.

On the test re-run, the values are different:

AssertionError: 592958 not less than 518066

(again, varying between test runs by ~500 or so).

@markshannon commented on the original PR:

sys.gettotalrefcount() is the total refcount per interpreter, but sys.getallocatedblocks() seems to be the total number of allocated blocks per process. If multiple interpreters were involved, I could see this test failing. Otherwise, it is puzzling.

This PR does no refcounting, allocation or deallocation. My guess is that this PR is exposing an already existing miscounting of references when a recursion error occurs. Just a guess though.

The problem doesn't appear to be an issue with running the test suite as a single process - Android isn't affected in CI, I can't reproduce the issue on my own macOS machine running a single-process run locally.

However, I also can't reliably reproduce the problem locally on iOS. Running the fully test suite locally, this test passes reliably.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other

Linked PRs

  • gh-130384: Skip a test_getallocatedblocks test pre-condition on iOS. #130385

Activity

  1. freakboy3742
    added
    3.14bugs and security fixesbugs and security fixes
    OS-ios
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Feb 20, 2025
  2. picnixz
    added
    testsTests in the Lib/test dirTests in the Lib/test dir
    on Feb 21, 2025
  3. markshannon commented on Feb 24, 2025

    @markshannon
    markshannon
    on Feb 24, 2025
    Member
    More actions

    @freakboy3742 do you know (or can you easily find out) what the numbers for a and sys.gettotalrefcount() are on main, with the tests passing?

    Knowing the delta might give me some hint as to where a leak might be happening.

  4. markshannon commented on Feb 24, 2025

    @markshannon
    markshannon
    on Feb 24, 2025
    Member
    More actions

    While I can't tell why this test is failing only for iOS in CI, the precondition is incorrect, as the number of allocated blocks is per-process and the reference count is per interpreter.

    The comment in C function sys_getallocatedblocks_impl says "It might make sense to return the count for just the current interpreter." We should do that.

    Reacted by Russell Keith-Magee
  5. markshannon
    added a commit that references this issue on Feb 24, 2025

    gh-130384: Skip a test_getallocatedblocks test pre-condition on iOS. (G…

    8a76eb8
  6. freakboy3742 commented on Feb 24, 2025

    @freakboy3742
    freakboy3742
    on Feb 24, 2025
    ContributorAuthor
    More actions

    The PR disabling the precondition has been merged, so I'm going to close this issue. The fix to get_sysallocatedblocks_impl can be handled separately, and the pre-condition re-enabled on iOS if that approach works.

  7. freakboy3742
    closed this as completedon Feb 24, 2025
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

    3.14bugs and security fixesbugs and security fixesOS-iostestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    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.