Skip to content

Fix a compiler warning in _xxsubinterpretermodule.c - #103245

Merged
Yhg1s merged 1 commit into
python:mainfrom
Yhg1s:xxsubinterp-warning
Apr 4, 2023
Merged

Yhg1s merged 1 commit into
python:mainfrom
Yhg1s:xxsubinterp-warning

Conversation

@Yhg1s

@Yhg1s Yhg1s commented Apr 4, 2023

Copy link
Copy Markdown
Member

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.

@ericsnowcurrently ericsnowcurrently 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.

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
Copy Markdown
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

5 participants