Skip to content

Crash whenever _Py_FatalErrorFormat() is called on Windows #145498

@e4lam

Description

@e4lam

Bug report

Bug description:

Whenever _Py_FatalErrorFormat() is called for whatever reason on Windows, we crash. In Python/pylifecycle.c, it calls fatal_error() like this:

fatal_error(fd, 0, NULL, NULL, -1);

Notice that the fourth argument of this call, msg, is being passed a NULL pointer. Then at line 3563 inside fatal_error(), we have the following call to fatal_output_debug() that is guarded by #ifdef MS_WINDOWS:
fatal_output_debug(msg);

This then goes into fatal_output_debug() where at line 3275, we dereference the NULL msg pointer and crash:
msglen = strlen(msg);

I'm guessing that we should guard against msg != NULL either before calling fatal_output_debug(), or perhaps inside fatal_output_debug() itself.

CPython versions tested on:

3.13 (but code remains the same in main as of writing)

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions