(Merge 3.4) 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. _read_null() and _sigabrt() don't accept parameters.
This commit is contained in:
commit
6b8e0ed562
|
@ -194,10 +194,10 @@ class FaultHandlerTests(unittest.TestCase):
|
||||||
self.check_fatal_error("""
|
self.check_fatal_error("""
|
||||||
import faulthandler
|
import faulthandler
|
||||||
faulthandler.enable()
|
faulthandler.enable()
|
||||||
faulthandler._read_null(True)
|
faulthandler._sigsegv(True)
|
||||||
""",
|
""",
|
||||||
3,
|
3,
|
||||||
'(?:Segmentation fault|Bus error|Illegal instruction)')
|
'Segmentation fault')
|
||||||
|
|
||||||
def test_enable_file(self):
|
def test_enable_file(self):
|
||||||
with temporary_filename() as filename:
|
with temporary_filename() as filename:
|
||||||
|
|
|
@ -843,24 +843,16 @@ faulthandler_read_null(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
volatile int *x;
|
volatile int *x;
|
||||||
volatile int y;
|
volatile int y;
|
||||||
int release_gil = 0;
|
|
||||||
if (!PyArg_ParseTuple(args, "|i:_read_null", &release_gil))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
faulthandler_suppress_crash_report();
|
faulthandler_suppress_crash_report();
|
||||||
x = NULL;
|
x = NULL;
|
||||||
if (release_gil) {
|
y = *x;
|
||||||
Py_BEGIN_ALLOW_THREADS
|
|
||||||
y = *x;
|
|
||||||
Py_END_ALLOW_THREADS
|
|
||||||
} else
|
|
||||||
y = *x;
|
|
||||||
return PyLong_FromLong(y);
|
return PyLong_FromLong(y);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static void
|
||||||
faulthandler_sigsegv(PyObject *self, PyObject *args)
|
faulthandler_raise_sigsegv(void)
|
||||||
{
|
{
|
||||||
faulthandler_suppress_crash_report();
|
faulthandler_suppress_crash_report();
|
||||||
#if defined(MS_WINDOWS)
|
#if defined(MS_WINDOWS)
|
||||||
|
@ -880,6 +872,22 @@ faulthandler_sigsegv(PyObject *self, PyObject *args)
|
||||||
#else
|
#else
|
||||||
raise(SIGSEGV);
|
raise(SIGSEGV);
|
||||||
#endif
|
#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;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1020,12 +1028,12 @@ static PyMethodDef module_methods[] = {
|
||||||
"'signum' registered by register()")},
|
"'signum' registered by register()")},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{"_read_null", faulthandler_read_null, METH_VARARGS,
|
{"_read_null", faulthandler_read_null, METH_NOARGS,
|
||||||
PyDoc_STR("_read_null(release_gil=False): read from NULL, raise "
|
PyDoc_STR("_read_null(): read from NULL, raise "
|
||||||
"a SIGSEGV or SIGBUS signal depending on the platform")},
|
"a SIGSEGV or SIGBUS signal depending on the platform")},
|
||||||
{"_sigsegv", faulthandler_sigsegv, METH_VARARGS,
|
{"_sigsegv", faulthandler_sigsegv, METH_VARARGS,
|
||||||
PyDoc_STR("_sigsegv(): raise a SIGSEGV signal")},
|
PyDoc_STR("_sigsegv(release_gil=False): raise a SIGSEGV signal")},
|
||||||
{"_sigabrt", faulthandler_sigabrt, METH_VARARGS,
|
{"_sigabrt", faulthandler_sigabrt, METH_NOARGS,
|
||||||
PyDoc_STR("_sigabrt(): raise a SIGABRT signal")},
|
PyDoc_STR("_sigabrt(): raise a SIGABRT signal")},
|
||||||
{"_sigfpe", (PyCFunction)faulthandler_sigfpe, METH_NOARGS,
|
{"_sigfpe", (PyCFunction)faulthandler_sigfpe, METH_NOARGS,
|
||||||
PyDoc_STR("_sigfpe(): raise a SIGFPE signal")},
|
PyDoc_STR("_sigfpe(): raise a SIGFPE signal")},
|
||||||
|
|
Loading…
Reference in New Issue