From 9db521c4a8216e9fb0af1c2dfff08f077f5eaf9c Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 30 Sep 2014 13:49:09 +0200 Subject: faulthandler: _sigsegv() and _sigabrt() don't accept parameters --- Modules/faulthandler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index 6a145dc..cf08aa5 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -1006,9 +1006,9 @@ static PyMethodDef module_methods[] = { {"_read_null", faulthandler_read_null, METH_VARARGS, PyDoc_STR("_read_null(release_gil=False): read from NULL, raise " "a SIGSEGV or SIGBUS signal depending on the platform")}, - {"_sigsegv", faulthandler_sigsegv, METH_VARARGS, + {"_sigsegv", faulthandler_sigsegv, METH_NOARGS, PyDoc_STR("_sigsegv(): raise a SIGSEGV signal")}, - {"_sigabrt", faulthandler_sigabrt, METH_VARARGS, + {"_sigabrt", faulthandler_sigabrt, METH_NOARGS, PyDoc_STR("_sigabrt(): raise a SIGABRT signal")}, {"_sigfpe", (PyCFunction)faulthandler_sigfpe, METH_NOARGS, PyDoc_STR("_sigfpe(): raise a SIGFPE signal")}, -- cgit v0.12 From 5083828d65b6eb617d4333a1c0c4c9b7c3f452a6 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 30 Sep 2014 13:54:14 +0200 Subject: faulthandler: test_gil_released() now uses _sigsegv() instead of _read_null(), because _read_null() cannot be used on AIX. On AIX, reading from NULL is allowed: the first page of memory is a mapped read-only on AIX. --- Lib/test/test_faulthandler.py | 4 ++-- Modules/faulthandler.c | 38 +++++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py index 97dffd2..8dcefe4 100644 --- a/Lib/test/test_faulthandler.py +++ b/Lib/test/test_faulthandler.py @@ -184,10 +184,10 @@ class FaultHandlerTests(unittest.TestCase): self.check_fatal_error(""" import faulthandler faulthandler.enable() - faulthandler._read_null(True) + faulthandler._sigsegv(True) """, 3, - '(?:Segmentation fault|Bus error|Illegal instruction)') + 'Segmentation fault') def test_enable_file(self): with temporary_filename() as filename: diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index cf08aa5..c17ffd8 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -809,23 +809,15 @@ faulthandler_read_null(PyObject *self, PyObject *args) { volatile int *x; volatile int y; - int release_gil = 0; - if (!PyArg_ParseTuple(args, "|i:_read_null", &release_gil)) - return NULL; x = NULL; - if (release_gil) { - Py_BEGIN_ALLOW_THREADS - y = *x; - Py_END_ALLOW_THREADS - } else - y = *x; + y = *x; return PyLong_FromLong(y); } -static PyObject * -faulthandler_sigsegv(PyObject *self, PyObject *args) +static void +faulthandler_raise_sigsegv(void) { #if defined(MS_WINDOWS) /* For SIGSEGV, faulthandler_fatal_error() restores the previous signal @@ -844,6 +836,22 @@ faulthandler_sigsegv(PyObject *self, PyObject *args) #else raise(SIGSEGV); #endif +} + +static PyObject * +faulthandler_sigsegv(PyObject *self, PyObject *args) +{ + int release_gil = 0; + if (!PyArg_ParseTuple(args, "|i:_read_null", &release_gil)) + return NULL; + + if (release_gil) { + Py_BEGIN_ALLOW_THREADS + faulthandler_raise_sigsegv(); + Py_END_ALLOW_THREADS + } else { + faulthandler_raise_sigsegv(); + } Py_RETURN_NONE; } @@ -1003,11 +1011,11 @@ static PyMethodDef module_methods[] = { "'signum' registered by register()")}, #endif - {"_read_null", faulthandler_read_null, METH_VARARGS, - PyDoc_STR("_read_null(release_gil=False): read from NULL, raise " + {"_read_null", faulthandler_read_null, METH_NOARGS, + PyDoc_STR("_read_null(): read from NULL, raise " "a SIGSEGV or SIGBUS signal depending on the platform")}, - {"_sigsegv", faulthandler_sigsegv, METH_NOARGS, - PyDoc_STR("_sigsegv(): raise a SIGSEGV signal")}, + {"_sigsegv", faulthandler_sigsegv, METH_VARARGS, + PyDoc_STR("_sigsegv(release_gil=False): raise a SIGSEGV signal")}, {"_sigabrt", faulthandler_sigabrt, METH_NOARGS, PyDoc_STR("_sigabrt(): raise a SIGABRT signal")}, {"_sigfpe", (PyCFunction)faulthandler_sigfpe, METH_NOARGS, -- cgit v0.12