Skip to content

New warning: "‘subobj’ may be used uninitialized in this function" in Objects/bytes_methods.c #102941

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

Closed
sobolevn opened this issue Mar 23, 2023 · 1 comment
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Mar 23, 2023

Example:
Снимок экрана 2023-03-23 в 12 05 59

This looks like a false-positive, because subobj is always initialized in stringlib_parse_args_finds(function_name, args, &subobj, &start, &end):

static PyObject *
_Py_bytes_tailmatch(const char *str, Py_ssize_t len,
const char *function_name, PyObject *args,
int direction)
{
Py_ssize_t start = 0;
Py_ssize_t end = PY_SSIZE_T_MAX;
PyObject *subobj;
int result;
if (!stringlib_parse_args_finds(function_name, args, &subobj, &start, &end))
return NULL;
if (PyTuple_Check(subobj)) {
Py_ssize_t i;
for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) {
result = tailmatch(str, len, PyTuple_GET_ITEM(subobj, i),
start, end, direction);

Morever, it is used before in PyTuple_Check(subobj).

Any ideas on how to fix / silence it?
And why we get this warning only now? The code was not changed for 10 months.

Linked PRs

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Mar 23, 2023
@sobolevn
Copy link
Member Author

Maybe adding = NULL?

@sobolevn sobolevn self-assigned this Mar 23, 2023
sobolevn added a commit to sobolevn/cpython that referenced this issue Mar 23, 2023
@sobolevn sobolevn changed the title New warning: "‘subobj’ may be used uninitialized in this function" in Objects/bytes_methods.c New warning: "‘subobj’ may be used uninitialized in this function" in Objects/bytes_methods.c Mar 23, 2023
JelleZijlstra pushed a commit that referenced this issue Mar 27, 2023
Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this issue Mar 27, 2023
warsaw pushed a commit to warsaw/cpython that referenced this issue Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant