Skip to content

Possible NULL-related SystemError when interpreter is not fully initialized #161863

Open

Description

@sobolevn

Code:

cpython/Python/import.c

Lines 3921 to 3922 in 9f38636

mod = PyObject_CallMethodObjArgs(IMPORTLIB(interp), find_and_load,
abs_name, IMPORT_FUNC(interp), NULL);

Here IMPORTLIB(interp) can be NULL under rare conditions:

cpython/Python/import.c

Lines 95 to 96 in 9f38636

#define IMPORTLIB(interp) \
(interp)->imports.importlib

For example, when interpreter is not yet fully initialized.

Output:

» ./Programs/_freeze_module crash crash.py crash.h
Exception ignored in the internal traceback machinery:
SystemError: null argument to internal routine
# ...

Refs #161860 where I first found this case.
Refs #142662 where the initial reproducer was found.

I guess we should raise a different SystemError here with the text that imports are not yet fully initialized.

My proposal is to make the error message better here: it should state the interpreter is not fully initialized.

And ideally we can fix the freeze command as well later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions