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 — [3.14] gh-148284: Block inlining of gigantic functions in ceval.c for clang 22 by Fidget-Spinner · Pull Request #148326 · python/cpython

Conversation

@Fidget-Spinner

@Fidget-Spinner Fidget-Spinner commented Apr 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

It seems that on clang-22, the inliner is too aggressive on _PyEval_EvalFrameDefault when on computed goto interpreter. Together with some strange interaction with the stackref buffer, the function requires 40kB of stack space (!!!) versus the usual 1-2kB normally used.

This sets the inline limit to functions of max 512B stack space (1/4th of normal) allowed to be inlined in ceval.c. I checked the dissasembly and the new function uses about 2kB of stack.

This will need a forward-port to 3.15 too.

  • Issue: python -m test -v test_call segfault with clang 22.1.3 build #148284

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Fidget-Spinner
Block inlining of gigantic functions
012b8a9
@Fidget-Spinner
Fidget-Spinner requested review from corona10 and erlend-aasland as code owners April 10, 2026 08:42
@bedevere-app bedevere-app Bot added the awaiting core review label Apr 10, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Apr 10, 2026
python -m test -v test_call segfault with clang 22.1.3 build #148284
Closed
@Fidget-Spinner Fidget-Spinner changed the title [3.14] gh-148284: Block inlining of gigantic functions in ceval.c [3.14] gh-148284: Block inlining of gigantic functions in ceval.c for clang 22 Apr 10, 2026
blurb-it Bot and others added 3 commits April 10, 2026 09:21
@blurb-it
📜🤖 Added by blurb_it.
144522b
@Fidget-Spinner
remove unused function
9e14d47
@Fidget-Spinner
Merge branch 'block_inlining_of_gigantic_functions' of github.com:Fid…
ce5594f
…get-Spinner/cpython into block_inlining_of_gigantic_functions
@Fidget-Spinner
Fidget-Spinner requested a review from vstinner April 10, 2026 12:14
@vstinner

vstinner commented Apr 10, 2026

Copy link
Copy Markdown
Member

This will need a forward-port to 3.15 too.

If possible, I would prefer to fix the main branch first, and then backport to 3.14.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner

Fidget-Spinner commented Apr 10, 2026

Copy link
Copy Markdown
Member Author

If possible, I would prefer to fix the main branch first, and then backport to 3.14.

OK, I need to test on main first to see if there're issues there.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner reviewed Apr 10, 2026
View reviewed changes
Comment thread configure.ac
else
CFLAGS_CEVAL=""
fi
AC_SUBST([CFLAGS_CEVAL])

@vstinner vstinner Apr 10, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Can you document this new variable in https://docs.python.org/dev/using/configure.html#envvar-CFLAGS_ALIASING ?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Fidget-Spinner Fidget-Spinner Apr 10, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Is there a way to make this a private variable? I don't feel good exposing it for now.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread configure.ac
Comment on lines +7250 to +7253
// See gh-148284:
// Clang 22 seems to have interactions with inlining and the stackref buffer
// which cause 40kB of stack usage on x86-64 in buggy versions of _PyEval_EvalFrameDefault
// in computed goto interpreter. The normal usage seen is normally 1-2kB.

@vstinner vstinner Apr 10, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Reformat to 80 columns and minor cleanup:

Suggested change
// See gh-148284:
// Clang 22 seems to have interactions with inlining and the stackref buffer
// which cause 40kB of stack usage on x86-64 in buggy versions of _PyEval_EvalFrameDefault
// in computed goto interpreter. The normal usage seen is normally 1-2kB.
// See gh-148284: Clang 22 seems to have interactions with inlining
// and the stackref buffer which cause 40 kB of stack usage on x86-64
// in buggy versions of _PyEval_EvalFrameDefault() in computed goto
// interpreter. The normal usage seen is normally 1-2 kB.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread configure.ac
Comment on lines +7267 to +7268
// This number should be tuned to follow the C stack consumption
// in _PyEval_EvalFrameDefault on computed goto interpreter.

@vstinner vstinner Apr 10, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I suggest adding "Suppress inlining of functions whose stack size exceeds 512 bytes." to explain the purpose of this option:

Suggested change
// This number should be tuned to follow the C stack consumption
// in _PyEval_EvalFrameDefault on computed goto interpreter.
// gh-148284: Suppress inlining of functions whose stack size exceeds
// 512 bytes. This number should be tuned to follow the C stack
// consumption in _PyEval_EvalFrameDefault() on computed goto
// interpreter.

The Clang option is documented at: https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-max-stacksize

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner

vstinner commented Apr 10, 2026

Copy link
Copy Markdown
Member

In the past, when I tried to reduce the stack memory consumption on Python function calls, I used Py_NO_INLINE with success. But it seems harder to annotate functions used by ceval.c with Py_NO_INLINE, instead of the generic -finline-max-stacksize=512. I'm just a little bit worried that a similar issue occurs with other compilers (GCC, MSVC).

In ceval.c, I see that get_exception_handler() is already annotated with Py_NO_INLINE.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner

Fidget-Spinner commented Apr 10, 2026

Copy link
Copy Markdown
Member Author

@vstinner PR moved to retarget main at #148334

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner Fidget-Spinner closed this Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner left review comments
@erlend-aasland erlend-aasland Awaiting requested review from erlend-aasland erlend-aasland is a code owner
@corona10 corona10 Awaiting requested review from corona10 corona10 is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Fidget-Spinner @vstinner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.