Skip to content

[3.14] gh-157660: Fix stale TLBC caches in _remote_debugging (GH-157732) - #158007

Merged
pablogsal merged 2 commits into
python:3.14from
liuzhijie-0614:gh-157660-refresh-tlbc-cache-3.14-backport
Sep 27, 2026
Merged

pablogsal merged 2 commits into
python:3.14from
liuzhijie-0614:gh-157660-refresh-tlbc-cache-3.14-backport

Conversation

@liuzhijie-0614

@liuzhijie-0614 liuzhijie-0614 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #157732 to 3.14; fixes #157660. The main-branch PR is still open.

In free-threaded builds, TLBC arrays can grow or gain entries without changing tlbc_generation, leaving _remote_debugging with stale cached data. This can cause persistent Invalid tlbc_index errors or incorrect line numbers.

Refresh the cached array when a frame’s index exceeds its capacity or points to a cached NULL slot, while retaining the existing bounds checks.

Adds regression tests based on both reproducers in the issue.

`profiling.sampling` reporting errors or incorrect line numbers in free-threaded
builds when a thread-local bytecode array grows or gains entries after being cached.

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 3.14 adaptation preserves the cache refresh and bounds checks. The external-inspection suite and 100 repetitions of each TLBC regression test pass in a free-threaded debug build, including the test corrections pushed here.

@pablogsal
pablogsal enabled auto-merge (squash) September 27, 2026 19:47
@pablogsal
pablogsal merged commit 0a905eb into python:3.14 Sep 27, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants