Skip to content

bpo-38631: Add _Py_NO_RETURN to functions calling Py_FatalError() #18278

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

Merged
merged 1 commit into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Include/cpython/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ _PyObject_DebugTypeStats(FILE *out);
NDEBUG against a Python built with NDEBUG defined.

msg, expr and function can be NULL. */
PyAPI_FUNC(void) _PyObject_AssertFailed(
PyAPI_FUNC(void) _Py_NO_RETURN _PyObject_AssertFailed(
PyObject *obj,
const char *expr,
const char *msg,
Expand Down
16 changes: 1 addition & 15 deletions Modules/faulthandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,24 +1065,10 @@ faulthandler_sigsegv(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}

static void
static void _Py_NO_RETURN
faulthandler_fatal_error_thread(void *plock)
{
#ifndef __clang__
PyThread_type_lock *lock = (PyThread_type_lock *)plock;
#endif

Py_FatalError("in new thread");

#ifndef __clang__
/* Issue #28152: Py_FatalError() is declared with
__attribute__((__noreturn__)). GCC emits a warning without
"PyThread_release_lock()" (compiler bug?), but Clang is smarter and
emits a warning on the return. */

/* notify the caller that we are done */
PyThread_release_lock(lock);
#endif
}

static PyObject *
Expand Down
6 changes: 3 additions & 3 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ none_repr(PyObject *op)
}

/* ARGUSED */
static void
static void _Py_NO_RETURN
none_dealloc(PyObject* ignore)
{
/* This should never get called, but we also don't want to SEGV if
Expand Down Expand Up @@ -1784,7 +1784,7 @@ notimplemented_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
Py_RETURN_NOTIMPLEMENTED;
}

static void
static void _Py_NO_RETURN
notimplemented_dealloc(PyObject* ignore)
{
/* This should never get called, but we also don't want to SEGV if
Expand Down Expand Up @@ -2225,7 +2225,7 @@ _PyTrash_thread_destroy_chain(void)
}


void
void _Py_NO_RETURN
_PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
const char *file, int line, const char *function)
{
Expand Down
2 changes: 1 addition & 1 deletion Objects/setobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2529,7 +2529,7 @@ dummy_repr(PyObject *op)
return PyUnicode_FromString("<dummy key>");
}

static void
static void _Py_NO_RETURN
dummy_dealloc(PyObject* ignore)
{
Py_FatalError("deallocating <dummy key>");
Expand Down