Skip to content

New warning: ‘state’ may be used uninitialized in this function in _xxinterpchannelsmodule.c #101609

@sobolevn

Description

@sobolevn

I am not sure if this is a false-positive or not, but here's the warning:
Снимок экрана 2023-02-06 в 21 57 19

It happens on all GitHub PRs right now, example: https://github.com/python/cpython/pull/101600/files

Looks like it is the result of c67b005

🤔

Looks like it is not a false positive:

  1. (void)_PyCrossInterpreterData_UnregisterClass(state->ChannelIDType); uses state
  2. But, we can go to error, before state is initialized. For example, here: if (exceptions_init(mod) != 0) { goto error; }

Moreover, _PyCrossInterpreterData_UnregisterClass(state->ChannelIDType) might get NULL, because of this code:

    state->ChannelIDType = add_new_type(
            mod, &ChannelIDType_spec, _channelid_shared);
    if (state->ChannelIDType == NULL) {
        goto error;
    }

I am not sure that I understand this code.
When state->ChannelIDType is not NULL during error:? Why is _PyCrossInterpreterData_UnregisterClass(state->ChannelIDType) needed?

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions