Skip to content

Conversation

@gkirchou
Copy link
Contributor

@gkirchou gkirchou commented Dec 2, 2025

To stop the warning.

Reproduce steps:

./configure --enable-optimizations --with-lto
make -s -j $(nproc);

@gkirchou gkirchou requested a review from markshannon as a code owner December 2, 2025 15:00
@bedevere-app

This comment was marked as resolved.

@StanFromIreland
Copy link
Member

StanFromIreland commented Dec 2, 2025

We already have #132376 open for this (we also had #134207, but that's closed now).

@chris-eibl
Copy link
Member

See my comment on the issue. There is prior art and initializing in this hot path to silence a false positive warning is not (my) preferred solution.

@picnixz
Copy link
Member

picnixz commented Dec 2, 2025

Initialization in a hot path is not desired and it's also a false positive. I'm going to close this PR, sorry.

@picnixz picnixz closed this Dec 2, 2025
@vstinner
Copy link
Member

vstinner commented Dec 2, 2025

IMO this change is a reasonable fix for the warnings.

@picnixz
Copy link
Member

picnixz commented Dec 2, 2025

I think we should have checked the produced assembly to see whether this introduces a true overhead in an optimized build. Personally, I think the pragmas are fine (we do this elsewhere) but we could disable them in DEBUG mode so that we correctly catch a possible issue when it's not optimized.

@chris-eibl
Copy link
Member

chris-eibl commented Dec 2, 2025

Well, we can check and then we know for this compiler and version we've checked. And are at the mercy of all compilers and versions that they hopefully behave the same - i.e. do not produce needless initialization code we've put in to silence a false positive warning.

@chris-eibl
Copy link
Member

I think the pragmas are fine

I think so, too. It is good to have less warnings. It is even better to have less false positive warnings :)

@chris-eibl
Copy link
Member

OTOH, _PyEvalFramePushAndInit_Ex is not very hot and compared to what the function is doing, the initialization most probably will be lost in noise.
It just bugs me to let the compiler emit unneeded code 1 and to have to think about whether it is impactful or not when I know it definitely isn't needed ...
So I'll leave it up to others to decide how to get rid of the warning and am just happy when the warning is gone :)

Footnotes

  1. maybe I should use "potentially unneeded code": some compilers might be smart enough to omit it, most probably those that don't emit the warning :)

@chris-eibl chris-eibl reopened this Dec 6, 2025
@chris-eibl
Copy link
Member

Reopening per my comment above ...

@picnixz
Copy link
Member

picnixz commented Dec 6, 2025

If we want pragmas we have the other PR which should be preferred over this one.

It we want an explicit initialization we can use this one. OTOH while it is a false positive it may become a non-false positive if we were to change the code a bit so it may be worth doing the explicit initialiaztion.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. IMO it's a reasonable fix to avoid warnings about uninitialized variables.

@chris-eibl
Copy link
Member

As said I am fine either way and happy when the warning is gone.

Leaving up to @markshannon or @Fidget-Spinner.

Copy link
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

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

_PyEvalFramePushAndInit_Ex is only used by _DO_CALL_FUNCTION_EX. That uop already constructs a tuple args and ocassionally dict kwargs. This is thus nothing in comparison to those. We should just merge it. Any effect on performance is likely not even measurable.

@picnixz
Copy link
Member

picnixz commented Dec 6, 2025

Actually, the commit is not by this author?

EDIT: oh this is just an alt account, looks like the same person.

@picnixz picnixz marked this pull request as draft December 6, 2025 17:43
@picnixz picnixz marked this pull request as ready for review December 6, 2025 17:44
@picnixz
Copy link
Member

picnixz commented Dec 6, 2025

@Fidget-Spinner What about _PyEval_Vector?

@picnixz picnixz changed the title gh-142168: Initalize may be used but uninitialized stack_array. gh-142168: explicitly initialize stack_array in _PyEval_Vector and _PyEvalFramePushAndInit_Ex Dec 6, 2025
@Fidget-Spinner
Copy link
Member

_PyEval_Vector is a little trickier. It's actually in the hot path of vectorcalls to Python functions in C-to-Python calls. However, again I suspect the cost of this is so low with respect to everything else (frame creation and all that) it doesnt matter.

@picnixz picnixz merged commit 35142b1 into python:main Dec 6, 2025
108 checks passed
@picnixz
Copy link
Member

picnixz commented Dec 6, 2025

Let's merge this and if there is a noticeable performance loss, then people will complain :')

@gkirchou gkirchou deleted the 142168 branch December 8, 2025 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants