]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38631: Add _Py_NO_RETURN to functions calling Py_FatalError() (GH-18278)
authorVictor Stinner <vstinner@python.org>
Thu, 30 Jan 2020 12:09:11 +0000 (13:09 +0100)
committerGitHub <noreply@github.com>
Thu, 30 Jan 2020 12:09:11 +0000 (13:09 +0100)
Add _Py_NO_RETURN to functions calling Py_FatalError():

* _PyObject_AssertFailed()
* dummy_dealloc()
* faulthandler_fatal_error_thread()
* none_dealloc()
* notimplemented_dealloc()

Include/cpython/object.h
Modules/faulthandler.c
Objects/object.c
Objects/setobject.c

index 75e55995b57413ad1d6cd0930e7c3d46a7db118e..dc8fd6fa8987d7bee7c8736f70bd7d7bd1a9c65f 100644 (file)
@@ -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,
index b19401e94d85a5a683135a37e4fe1d0f24fd02fe..555e1afc9f82a63e565a78d782dc8e5b9baa4b9d 100644 (file)
@@ -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 *
index c5d28e5f8d75824ace1274ee4efdbcda971be17b..67a6386e2a51d8563483fc6ae15ca362808acf46 100644 (file)
@@ -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
@@ -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
@@ -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)
 {
index 924885d7505a0bf4bf37272a33fe9d928ad7c3c6..bb7c0b8f0456b8ae8d47bf534944a04fab09d249 100644 (file)
@@ -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>");