Skip to content

Keep perf trampolines intact during BOLT optimization - #1356

Merged
zanieb merged 1 commit into
astral-sh:mainfrom
zaniebot:fix-perf-trampoline-bolt
Oct 21, 2026
Merged

zanieb merged 1 commit into
astral-sh:mainfrom
zaniebot:fix-perf-trampoline-bolt

Conversation

@zaniebot

Copy link
Copy Markdown
Contributor

The 20261020 Linux x86-64 builds of CPython 3.13 and 3.14 can crash when the perf trampoline is enabled with -X perf or -X perf_jit. The trampoline's end marker shares an address with the following function, so BOLT can move the marker independently of the trampoline and invalidate the byte range CPython copies at runtime.

Add a padding byte after the end marker and exclude the trampoline from BOLT instrumentation and optimization to keep its code and boundaries intact.

@zanieb

zanieb commented Oct 21, 2026

Copy link
Copy Markdown
Member

Ugh looking into why this didn't get caught upstream I noticed we're skipping these tests python/cpython#128883

@jjhelmus

Copy link
Copy Markdown
Contributor

This crash may be caused by the switch to lld in the 20261020 release as part of #1327

@zanieb

zanieb commented Oct 21, 2026

Copy link
Copy Markdown
Member

That may have exposed it, but the issue exists independently

@jjhelmus

Copy link
Copy Markdown
Contributor

That may have exposed it, but the issue exists independently

Agreed. llvm/llvm-project#100096 mentions a similar address aliasing issue specific to glibc. The patch seems like a reasonable approach until a fix is made upstream.

@zanieb
zanieb marked this pull request as ready for review October 21, 2026 16:26
@zanieb
zanieb merged commit f0c8595 into astral-sh:main Oct 21, 2026
22 checks passed
zanieb added a commit to astral-sh/uv that referenced this pull request Oct 21, 2026
The `20261020` `python-build-standalone` release contains Linux x86-64
builds whose perf trampoline bounds can be invalidated by BOLT
(astral-sh/python-build-standalone#1356). Skip the entire release during
metadata sync and regenerate the embedded metadata so downloads for
`3.13.16`, `3.14.8`, and `3.15.0` point to their `20261013` builds. The
`20261021` entries for newer patch versions remain unchanged.

Stacked on #22802.

Co-authored-by: zaniebot <[email protected]>
mkanat added a commit to define-lang/define that referenced this pull request Oct 23, 2026
The 20261020 x86-64 Linux builds lose the perf trampoline's end label during BOLT optimization, so any interpreter run with -X perf segfaults at startup. That broke the profiler's CPU mode. Upstream fixed it in 20261021 (astral-sh/python-build-standalone#1356).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

3 participants