Issue #12058: Minor edits to comments in faulthandler

Patch written by Éric Araujo.
This commit is contained in:
Victor Stinner 2011-05-11 20:56:08 +02:00
parent 9dd41fa970
commit 410dd7d357
1 changed files with 18 additions and 18 deletions

View File

@ -53,8 +53,8 @@ static struct {
int exit; int exit;
char *header; char *header;
size_t header_len; size_t header_len;
/* The main thread always hold this lock. It is only released when /* The main thread always holds this lock. It is only released when
faulthandler_thread() is interrupted until this thread exits, or at faulthandler_thread() is interrupted before this thread exits, or at
Python exit. */ Python exit. */
PyThread_type_lock cancel_event; PyThread_type_lock cancel_event;
/* released by child thread when joined */ /* released by child thread when joined */
@ -218,18 +218,18 @@ faulthandler_dump_traceback_py(PyObject *self,
} }
/* Handler of SIGSEGV, SIGFPE, SIGABRT, SIGBUS and SIGILL signals. /* Handler for SIGSEGV, SIGFPE, SIGABRT, SIGBUS and SIGILL signals.
Display the current Python traceback, restore the previous handler and call Display the current Python traceback, restore the previous handler and call
the previous handler. the previous handler.
On Windows, don't call explictly the previous handler, because Windows On Windows, don't explicitly call the previous handler, because the Windows
signal handler would not be called (for an unknown reason). The execution of signal handler would not be called (for an unknown reason). The execution of
the program continues at faulthandler_fatal_error() exit, but the same the program continues at faulthandler_fatal_error() exit, but the same
instruction will raise the same fault (signal), and so the previous handler instruction will raise the same fault (signal), and so the previous handler
will be called. will be called.
This function is signal safe and should only call signal safe functions. */ This function is signal-safe and should only call signal-safe functions. */
static void static void
faulthandler_fatal_error(int signum) faulthandler_fatal_error(int signum)
@ -267,7 +267,7 @@ faulthandler_fatal_error(int signum)
#ifdef WITH_THREAD #ifdef WITH_THREAD
/* SIGSEGV, SIGFPE, SIGABRT, SIGBUS and SIGILL are synchronous signals and /* SIGSEGV, SIGFPE, SIGABRT, SIGBUS and SIGILL are synchronous signals and
so are delivered to the thread that caused the fault. Get the Python are thus delivered to the thread that caused the fault. Get the Python
thread state of the current thread. thread state of the current thread.
PyThreadState_Get() doesn't give the state of the thread that caused the PyThreadState_Get() doesn't give the state of the thread that caused the
@ -289,7 +289,7 @@ faulthandler_fatal_error(int signum)
errno = save_errno; errno = save_errno;
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
if (signum == SIGSEGV) { if (signum == SIGSEGV) {
/* don't call explictly the previous handler for SIGSEGV in this signal /* don't explicitly call the previous handler for SIGSEGV in this signal
handler, because the Windows signal handler would not be called */ handler, because the Windows signal handler would not be called */
return; return;
} }
@ -457,7 +457,7 @@ faulthandler_thread(void *unused)
static void static void
cancel_dump_tracebacks_later(void) cancel_dump_tracebacks_later(void)
{ {
/* notify cancellation */ /* Notify cancellation */
PyThread_release_lock(thread.cancel_event); PyThread_release_lock(thread.cancel_event);
/* Wait for thread to join */ /* Wait for thread to join */
@ -781,7 +781,7 @@ faulthandler_sigsegv(PyObject *self, PyObject *args)
#if defined(MS_WINDOWS) #if defined(MS_WINDOWS)
/* For SIGSEGV, faulthandler_fatal_error() restores the previous signal /* For SIGSEGV, faulthandler_fatal_error() restores the previous signal
handler and then gives back the execution flow to the program (without handler and then gives back the execution flow to the program (without
calling explicitly the previous error handler). In a normal case, the explicitly calling the previous error handler). In a normal case, the
SIGSEGV was raised by the kernel because of a fault, and so if the SIGSEGV was raised by the kernel because of a fault, and so if the
program retries to execute the same instruction, the fault will be program retries to execute the same instruction, the fault will be
raised again. raised again.
@ -805,11 +805,11 @@ faulthandler_sigfpe(PyObject *self, PyObject *args)
PowerPC. Use volatile to disable compile-time optimizations. */ PowerPC. Use volatile to disable compile-time optimizations. */
volatile int x = 1, y = 0, z; volatile int x = 1, y = 0, z;
z = x / y; z = x / y;
/* if the division by zero didn't raise a SIGFPE (e.g. on PowerPC), /* If the division by zero didn't raise a SIGFPE (e.g. on PowerPC),
raise it manually */ raise it manually. */
raise(SIGFPE); raise(SIGFPE);
/* use z to make quiet a compiler warning, but this line /* This line is never reached, but we pretend to make something with z
is never reached */ to silence a compiler warning. */
return PyLong_FromLong(z); return PyLong_FromLong(z);
} }
@ -977,14 +977,14 @@ static PyMethodDef module_methods[] = {
{"_stack_overflow", (PyCFunction)faulthandler_stack_overflow, METH_NOARGS, {"_stack_overflow", (PyCFunction)faulthandler_stack_overflow, METH_NOARGS,
PyDoc_STR("_stack_overflow(): recursive call to raise a stack overflow")}, PyDoc_STR("_stack_overflow(): recursive call to raise a stack overflow")},
#endif #endif
{NULL, NULL} /* terminator */ {NULL, NULL} /* sentinel */
}; };
static struct PyModuleDef module_def = { static struct PyModuleDef module_def = {
PyModuleDef_HEAD_INIT, PyModuleDef_HEAD_INIT,
"faulthandler", "faulthandler",
module_doc, module_doc,
0, /* non negative size to be able to unload the module */ 0, /* non-negative size to be able to unload the module */
module_methods, module_methods,
NULL, NULL,
faulthandler_traverse, faulthandler_traverse,
@ -998,8 +998,8 @@ PyInit_faulthandler(void)
return PyModule_Create(&module_def); return PyModule_Create(&module_def);
} }
/* Call faulthandler.enable() if PYTHONFAULTHANDLER environment variable is /* Call faulthandler.enable() if the PYTHONFAULTHANDLER environment variable
defined, or if sys._xoptions has a 'faulthandler' key. */ is defined, or if sys._xoptions has a 'faulthandler' key. */
static int static int
faulthandler_env_options(void) faulthandler_env_options(void)