Skip to content

Fix a compiler warning in _xxsubinterpretermodule.c #103245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2023

Conversation

Yhg1s
Copy link
Member

@Yhg1s Yhg1s commented Apr 4, 2023

Fix a (correct) warning about potential uses of uninitialized memory in _xxsubinterpreter. Unlike newly allocated PyObject structs or global structs, stack-allocated structs are not initialised, and a few places in the code expect the _sharedexception struct data to be NULL when not set.

_xxsubinterpreter. Unlike newly allocated PyObject structs or global
structs, stack-allocated structs are not initialised, and a few places in
the code expect the _sharedexception struct data to be either NULL or
initialised.
Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

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

LGTM

@Yhg1s Yhg1s merged commit 89e6a34 into python:main Apr 4, 2023
@Yhg1s Yhg1s deleted the xxsubinterp-warning branch April 4, 2023 14:53
@gaogaotiantian
Copy link
Member

In my opinion, the fix in #103048 is slightly better. Function wise they are equivalent as of now, but no_exception has better semantics. Also, in the future if struct _sharedexception is changed(this is a local use data structure), one less line of code to worry about. If we only want to zero initialize the struct, _sharedexception exc = {0}; can also save the trouble to modify it in the future in case the struct is changed.

gaogaotiantian pushed a commit to gaogaotiantian/cpython that referenced this pull request Apr 8, 2023
Fix a (correct) warning about potential uses of uninitialized memory in
_xxsubinterpreter. Unlike newly allocated PyObject structs or global
structs, stack-allocated structs are not initialised, and a few places in
the code expect the _sharedexception struct data to be either NULL or
initialised.
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
Fix a (correct) warning about potential uses of uninitialized memory in
_xxsubinterpreter. Unlike newly allocated PyObject structs or global
structs, stack-allocated structs are not initialised, and a few places in
the code expect the _sharedexception struct data to be either NULL or
initialised.
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.

5 participants